Class: Rjq::AST::Recurse

Inherits:
Node
  • Object
show all
Defined in:
lib/rjq/ast.rb

Instance Attribute Summary

Attributes inherited from Node

#source_span

Instance Method Summary collapse

Methods inherited from Node

#assign_value, #invalid_path_message, #take, #with_source_span

Instance Method Details

#eval(input, _context) ⇒ Object



1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
# File 'lib/rjq/ast.rb', line 1130

def eval(input, _context)
  values = []
  visit = lambda do |value|
    values << value
    case value
    when Array
      value.each { |item| visit.call(item) }
    when Hash
      value.each_value { |item| visit.call(item) }
    end
  end
  visit.call(input)
  values
end

#paths(input, _context) ⇒ Object



1145
1146
1147
# File 'lib/rjq/ast.rb', line 1145

def paths(input, _context)
  Path.paths(input, leaves_only: false)
end