You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

navigable_hash

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

navigable_hash

1.3.0
bundlerRubygems
Version published
Maintainers
2
Created
Source

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

  • Fork it
  • 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

FAQs

Package last updated on 24 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts