Skip to content

listrophy/gists

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gists

Stupid little methods that probably should be in ruby core, but aren’t.

Installation

It’s a gem. Install it how you want.

Bundler-enabled projects:

gem 'gists'

Other projects:

$ gem install gists
require 'gists'

Usage

As of now, there are three methods:

  • Kernel#random_in *enumerable_or_many_args

  • Object#.in? enumerable

  • String#surround *one_or_two_args

>> require 'rubygems'
=> true
>> require 'gists'
=> true
>> random_in 1, 2, 3, 4
=> 2
>> random_in 1..4
=> 4
>> random_in [1, 2, 3, 4]
=> 3
>> 'test'.in? ['development', 'test']
=> true
>> "SELECT * FROM users WHERE name LIKE '%s'" % 'bob'.surround('%') # you should probably sanitize, too
=> "SELECT * FROM users WHERE name LIKE '%bob%'"

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Bradley Grzesiak. See LICENSE for details.

About

Stupid little methods that probably should be in ruby core, but aren't.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages