Class: Gobstones::Lang::Commands::SingleAssignment
- Inherits:
-
Object
- Object
- Gobstones::Lang::Commands::SingleAssignment
- Includes:
- EqualityDefinition
- Defined in:
- lib/gobstones/lang/commands/single_assignment.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#var_name ⇒ Object
readonly
Returns the value of attribute var_name.
Instance Method Summary collapse
- #equality_attributes ⇒ Object
- #evaluate(context) ⇒ Object
-
#initialize(var_name, expression) ⇒ SingleAssignment
constructor
A new instance of SingleAssignment.
Methods included from EqualityDefinition
Constructor Details
#initialize(var_name, expression) ⇒ SingleAssignment
Returns a new instance of SingleAssignment.
11 12 13 14 |
# File 'lib/gobstones/lang/commands/single_assignment.rb', line 11 def initialize(var_name, expression) @var_name = var_name @expression = expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
9 10 11 |
# File 'lib/gobstones/lang/commands/single_assignment.rb', line 9 def expression @expression end |
#var_name ⇒ Object (readonly)
Returns the value of attribute var_name.
9 10 11 |
# File 'lib/gobstones/lang/commands/single_assignment.rb', line 9 def var_name @var_name end |
Instance Method Details
#equality_attributes ⇒ Object
16 17 18 |
# File 'lib/gobstones/lang/commands/single_assignment.rb', line 16 def equality_attributes %i[var_name expression] end |
#evaluate(context) ⇒ Object
20 21 22 |
# File 'lib/gobstones/lang/commands/single_assignment.rb', line 20 def evaluate(context) context.set(var_name, expression.evaluate(context)) end |