Skip to content
Stupid little methods that probably should be in ruby core, but aren't. http://rubygems.org/gems/gists
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.document
.gitignore
.rvmrc
Gemfile
LICENSE
README.rdoc
Rakefile
VERSION
gists.gemspec

README.rdoc

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

Copyright © 2010 Bradley Grzesiak. See LICENSE for details.

Something went wrong with that request. Please try again.