Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hash Query

Build Status Code Climate Coverage Status Dependency Status

Provides a css-like selector system for querying values out of deeply nested hashes.

Usage

require 'hash_query'

hash = { 
  a: 1, 
  b: { 
    c: {
      d: { 
        e: 2, 
        f: 3 
      }
    },
    cc: [
      3,
      {
        g: 6,
        h: 7,
        i: => [ 8, 9, 10, 11 ]
      },
      4,
      5
    ]
  }
}

Requiring hash_query will provide two new methods, Hash#query_value and Hash#query_values. Both methods take a single string to represent a key or keys to be found in the hash.

To find a the first key match:

hash.query_value('e')   # => 2
hash.query_value('c d') # => { e: 2, f: 3 }

Contributing

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

About

Provides a css-like selector system for querying values out of deeply nested hashes.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages