Class: TreeFilter
- Inherits:
-
Object
- Object
- TreeFilter
- Defined in:
- lib/tree_filter.rb
Overview
Allows filtering of complex data-structure using a string query language.
Query examples:
name,environments # Select specific attributes from a hash
environments[id,last_deploy] # Select attributes from sub-hash
environments[*] # Select all attributes
Two special objects are provided for richer data structure evaluation, Leaf and Defer. See their documentation respectively.
More examples in unit specs.
Defined Under Namespace
Modules: JsonTerminal Classes: Defer, Leaf, NullSlice, Slice
Instance Method Summary collapse
- #filter(value) ⇒ Object
-
#initialize(input) ⇒ TreeFilter
constructor
A new instance of TreeFilter.
- #inspect ⇒ Object
Constructor Details
#initialize(input) ⇒ TreeFilter
Returns a new instance of TreeFilter.
16 17 18 |
# File 'lib/tree_filter.rb', line 16 def initialize(input) @input = StringIO.new(input) end |
Instance Method Details
#filter(value) ⇒ Object
20 21 22 |
# File 'lib/tree_filter.rb', line 20 def filter(value) slice.filter(value) end |
#inspect ⇒ Object
69 70 71 |
# File 'lib/tree_filter.rb', line 69 def inspect "<TreeFilter #{slice.attrs.inspect}>" end |