Class: Rjq::AST::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#source_spanObject (readonly)

Returns the value of attribute source_span.



48
49
50
# File 'lib/rjq/ast.rb', line 48

def source_span
  @source_span
end

Instance Method Details

#assign_value(copy, input, context, value) ⇒ Object



71
72
73
74
# File 'lib/rjq/ast.rb', line 71

def assign_value(copy, input, context, value)
  paths(input, context).each { |path| copy = Path.set(copy, path, value) }
  copy
end

#eval(_input, _context) ⇒ Object

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/rjq/ast.rb', line 55

def eval(_input, _context)
  raise NotImplementedError, "#{self.class}#eval"
end

#invalid_path_message(result, _input, _context) ⇒ Object



67
68
69
# File 'lib/rjq/ast.rb', line 67

def invalid_path_message(result, _input, _context)
  "Invalid path expression with result #{JSON::Dumper.dump(result, indent: nil)}"
end

#paths(_input, _context) ⇒ Object

Raises:



63
64
65
# File 'lib/rjq/ast.rb', line 63

def paths(_input, _context)
  raise TypeError, "#{self.class} is not a path expression"
end

#take(input, context, count) ⇒ Object



59
60
61
# File 'lib/rjq/ast.rb', line 59

def take(input, context, count)
  eval(input, context).first(count)
end

#with_source_span(span) ⇒ Object



50
51
52
53
# File 'lib/rjq/ast.rb', line 50

def with_source_span(span)
  @source_span = span
  self
end