0.0
No commit activity in last 3 years
No release in over 3 years
Allows a hash to be navigated with dot notation or indifferent access.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
= 0.6.7
= 1.8.2
= 0.9.12.2
= 10.1.0
= 2.14
 Project Readme

NavigableHash

Version Dependencies Build Status Coverage Code Climate

NavigableHash was built as lightweight and quick way to navigate through a hash or array object using the familiar ruby dot notation. See 'Usage' below for examples. Keys as strings or symbols don't matter, its all included.

Installation

Add this line to your application's Gemfile:

gem 'navigable_hash'

And then execute:

$ bundle

Or install it yourself as:

$ gem install navigable_hash

Usage

(Check out the rspec tests for coverage examples)

Most basic usage:

test_hash = { :example_key => 'example value' }
navigable_hash = NavigableHash.new(test_hash)

navigable_hash.example_key
# => 'example_value'

More:

new_hash = { :second_key => { :inner_key => true }, :array_item => [{}, "string", :symbol] }
navigable_hash = NavigableHash.new(new_hash)

navigable_hash.second_key.inner_key
# => true

navigable_hash.array_item.last
# => :symbol

Call Agnostic (key as a string, symbol or dot notation):

new_hash = { "first_key" => "value 1" }
navigable_hash = NavigableHash.new(new_hash)

navigable_hash.first_key
navigable_hash[:first_key]
navigable_hash["first_key"]
# => "value 1"

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request