DotNotation
Simple-ish enumberable-simplifier. Useful for APIs like Twitter, etc
If you have a hash or an array or something that quacks like one, you can do stuff like this:
require 'dot_notation'
h = {a: {b: {c: [{d: 'hi'}]}}}
h[:a][:b][:c][0][:d] # ugh, what a pain
#=> 'hi'
h.extend(DotNotation)
h.dot('a.b.c.0.d') # yay!
#=> 'hi'
h.dot('a.b.c.foo.bar.bz.whatever.124.whocares') # automagic nilchecks
#=> nil
Installation
Add this line to your application's Gemfile:
gem 'dot_notation'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dot_notation
Contributing
- Fork it ( http://github.com//dot_notation/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request