Class: Code::Node::Equal
- Inherits:
-
Code::Node
- Object
- Code::Node
- Code::Node::Equal
- Defined in:
- lib/code/node/equal.rb
Instance Method Summary collapse
- #evaluate(**args) ⇒ Object
-
#initialize(equal) ⇒ Equal
constructor
A new instance of Equal.
Constructor Details
#initialize(equal) ⇒ Equal
4 5 6 7 8 |
# File 'lib/code/node/equal.rb', line 4 def initialize(equal) @left = equal.fetch(:left).fetch(:name) @operator = equal.fetch(:operator) @right = ::Code::Node::Statement.new(equal.fetch(:right)) end |
Instance Method Details
#evaluate(**args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/code/node/equal.rb', line 10 def evaluate(**args) right = @right.evaluate(**args) context = args.fetch(:context) if operator if context[left] context[left] = simple_call(context[left], operator, right, **args) else raise ::Code::Error::UndefinedVariable.new("#{left} is undefined") end else context[left] = right end end |