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.
202 203 204 205 |
# File 'lib/kalc/ast.rb', line 202 def initialize(identifier, value) @variable = identifier.to_s.strip @value = value end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
199 200 201 |
# File 'lib/kalc/ast.rb', line 199 def identifier @identifier end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
200 201 202 |
# File 'lib/kalc/ast.rb', line 200 def value @value end |
Instance Method Details
#eval(context) ⇒ Object
207 208 209 |
# File 'lib/kalc/ast.rb', line 207 def eval(context) context.add_variable(@variable, @value) end |