Class: Kalc::Ast::Negative
- Inherits:
-
Object
- Object
- Kalc::Ast::Negative
- Defined in:
- lib/kalc/ast.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #eval(context) ⇒ Object
-
#initialize(value) ⇒ Negative
constructor
A new instance of Negative.
Constructor Details
#initialize(value) ⇒ Negative
Returns a new instance of Negative.
39 40 41 |
# File 'lib/kalc/ast.rb', line 39 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
37 38 39 |
# File 'lib/kalc/ast.rb', line 37 def value @value end |
Instance Method Details
#eval(context) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/kalc/ast.rb', line 43 def eval(context) begin -(@value.eval(context)) rescue @value.eval(context) end end |