Class: Rjq::AST::Context
- Inherits:
-
Object
- Object
- Rjq::AST::Context
- Defined in:
- lib/rjq/ast.rb
Instance Attribute Summary collapse
-
#binding_variable_paths ⇒ Object
readonly
Returns the value of attribute binding_variable_paths.
-
#current_path ⇒ Object
readonly
Returns the value of attribute current_path.
-
#functions ⇒ Object
readonly
Returns the value of attribute functions.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(variables: {}, functions: {}, options: {}, current_path: [], binding_variable_paths: {}) ⇒ Context
constructor
A new instance of Context.
- #with_function(name, arity, definition) ⇒ Object
- #with_functions(new_functions) ⇒ Object
- #with_options(new_options) ⇒ Object
- #with_path_state(current_path:, variables: binding_variable_paths) ⇒ Object
- #with_variable(name, value) ⇒ Object
Constructor Details
#initialize(variables: {}, functions: {}, options: {}, current_path: [], binding_variable_paths: {}) ⇒ Context
Returns a new instance of Context.
10 11 12 13 14 15 16 |
# File 'lib/rjq/ast.rb', line 10 def initialize(variables: {}, functions: {}, options: {}, current_path: [], binding_variable_paths: {}) @variables = variables @functions = functions @options = @current_path = current_path @binding_variable_paths = binding_variable_paths end |
Instance Attribute Details
#binding_variable_paths ⇒ Object (readonly)
Returns the value of attribute binding_variable_paths.
8 9 10 |
# File 'lib/rjq/ast.rb', line 8 def binding_variable_paths @binding_variable_paths end |
#current_path ⇒ Object (readonly)
Returns the value of attribute current_path.
8 9 10 |
# File 'lib/rjq/ast.rb', line 8 def current_path @current_path end |
#functions ⇒ Object (readonly)
Returns the value of attribute functions.
8 9 10 |
# File 'lib/rjq/ast.rb', line 8 def functions @functions end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/rjq/ast.rb', line 8 def @options end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
8 9 10 |
# File 'lib/rjq/ast.rb', line 8 def variables @variables end |
Instance Method Details
#with_function(name, arity, definition) ⇒ Object
22 23 24 |
# File 'lib/rjq/ast.rb', line 22 def with_function(name, arity, definition) copy(functions: functions.merge([name, arity] => definition)) end |
#with_functions(new_functions) ⇒ Object
26 27 28 |
# File 'lib/rjq/ast.rb', line 26 def with_functions(new_functions) copy(functions: new_functions) end |
#with_options(new_options) ⇒ Object
34 35 36 |
# File 'lib/rjq/ast.rb', line 34 def () copy(options: ) end |
#with_path_state(current_path:, variables: binding_variable_paths) ⇒ Object
30 31 32 |
# File 'lib/rjq/ast.rb', line 30 def with_path_state(current_path:, variables: binding_variable_paths) copy(current_path: current_path, binding_variable_paths: variables) end |
#with_variable(name, value) ⇒ Object
18 19 20 |
# File 'lib/rjq/ast.rb', line 18 def with_variable(name, value) copy(variables: variables.merge(name => value)) end |