Class: TreeFilter

Inherits:
Object
  • Object
show all
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

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

#inspectObject


69
70
71
# File 'lib/tree_filter.rb', line 69

def inspect
  "<TreeFilter #{slice.attrs.inspect}>"
end