Class: Rjq::AST::Program

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

Instance Attribute Summary collapse

Attributes inherited from Node

#source_span

Instance Method Summary collapse

Methods inherited from Node

#assign_value, #invalid_path_message, #paths, #take, #with_source_span

Constructor Details

#initialize(body, definitions = [], directives = []) ⇒ Program

Returns a new instance of Program.



95
96
97
98
99
# File 'lib/rjq/ast.rb', line 95

def initialize(body, definitions = [], directives = [])
  @body = body
  @definitions = definitions
  @directives = directives
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



93
94
95
# File 'lib/rjq/ast.rb', line 93

def body
  @body
end

#definitionsObject (readonly)

Returns the value of attribute definitions.



93
94
95
# File 'lib/rjq/ast.rb', line 93

def definitions
  @definitions
end

#directivesObject (readonly)

Returns the value of attribute directives.



93
94
95
# File 'lib/rjq/ast.rb', line 93

def directives
  @directives
end

Instance Method Details

#context_with_definitions(context) ⇒ Object



105
106
107
# File 'lib/rjq/ast.rb', line 105

def context_with_definitions(context)
  apply_definitions(context)
end

#eval(input, context) ⇒ Object



101
102
103
# File 'lib/rjq/ast.rb', line 101

def eval(input, context)
  body.eval(input, context_with_definitions(context))
end