Class: Kalc::Ast::Identifier
- Inherits:
-
Object
- Object
- Kalc::Ast::Identifier
- Defined in:
- lib/kalc/ast.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #eval(context) ⇒ Object
-
#initialize(identifier, value) ⇒ Identifier
constructor
A new instance of Identifier.
Constructor Details
#initialize(identifier, value) ⇒ Identifier
Returns a new instance of Identifier.
204 205 206 207 |
# File 'lib/kalc/ast.rb', line 204 def initialize(identifier, value) @variable = identifier.to_s.strip @value = value end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
201 202 203 |
# File 'lib/kalc/ast.rb', line 201 def identifier @identifier end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
202 203 204 |
# File 'lib/kalc/ast.rb', line 202 def value @value end |
Instance Method Details
#eval(context) ⇒ Object
209 210 211 |
# File 'lib/kalc/ast.rb', line 209 def eval(context) context.add_variable(@variable, @value.eval(context)) end |