Created
November 13, 2012 23:16
-
-
Save ilake/4069075 to your computer and use it in GitHub Desktop.
LEVEL 4: ACTIVESUPPORT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| array.from(4) | |
| array.to(2) | |
| array.in_groups_of(3) | |
| array.split(2) | |
| array.index('word') | |
| apocalypse = DateTime.new(2012, 12, 21, 14, 27, 45) | |
| apocalypse.advance(years: 4, months: 3, weeks: 2, days: 1) | |
| apocalypse.tomorrow | |
| apocalypse.yesterday | |
|  | |
| options = {user: 'codeschool', lang: 'fr'} | |
| new_options = {user: 'codeschool', lang: 'fr', password: 'dunno'} | |
| options.diff(new_options) # {:password=>"dunno"} | |
| options.stringify_keys # {"user"=>"codeschool", "lang"=>"fr"} | |
| defaults = {:lang => 'en', :country => 'us'} | |
| options = {:lang => 'fr', :user => 'codeschool'} | |
| options.merge(defaults) #=> {:user=>"codeschool", :lang=>"en", :country=>"us"} | |
| options.reverse_merge(defaults) #=> {:user=>"codeschool", :lang=>"fr", :country=>"us"} | |
|  | |
| new_options = {user: 'codeschool', lang: 'fr', password: 'dunno'} | |
| new_options.except(:password) # {:user=>"codeschool", :lang=>"fr"} | |
| new_options.assert_valid_keys(:user, :lang) # Unknown key(s): password (ArgumentError) throws an exception if the hash contains any keys besides those listed here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment