Module: JSONSelect::Ast::SimpleSelector

Defined in:
lib/json_select/ast/simple_selector.rb

Instance Method Summary collapse

Instance Method Details

#to_astObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/json_select/ast/simple_selector.rb', line 3

def to_ast
  tests = []
  node  = {:tests => tests}
  
  if respond_to?(:a) and respond_to?(:b)
    tests << a.to_ast
    
    b.elements.each do |s|
      tests << s.to_ast
    end
    
  else
    self.elements.each do |s|
      tests << s.to_ast
    end
    
  end
  
  tests.compact!
  
  node
end