https://github.com/oleander/berg-rb
Find paths and values in complex Ruby hashes – much like css selectors
https://github.com/oleander/berg-rb
Last synced: over 1 year ago
JSON representation
Find paths and values in complex Ruby hashes – much like css selectors
- Host: GitHub
- URL: https://github.com/oleander/berg-rb
- Owner: oleander
- License: mit
- Created: 2016-06-20T22:42:16.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-21T02:29:27.000Z (about 10 years ago)
- Last Synced: 2025-01-21T14:47:47.249Z (over 1 year ago)
- Language: Ruby
- Size: 36.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://travis-ci.org/oleander/berg-rb)
# Berg
Find paths and values in complex Ruby hashes – much like css selectors.
## Install
```
$ gem install berg
```
## Example
``` ruby
require "berg"
data = { ... }
query = ".data[1].modules[2].content[-1].title.name"
value = "My value"
# Get query for #{value} in #{data}
Berg::Key.locate(data) do |leaf|
leaf.to_s.include?(value)
end
# Get value from #{query} in #{data}
Berg::Value.locate(data, query)
```