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.
38 39 40 |
# File 'lib/kalc/ast.rb', line 38 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
36 37 38 |
# File 'lib/kalc/ast.rb', line 36 def value @value end |
Instance Method Details
#eval(context) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/kalc/ast.rb', line 42 def eval(context) begin -(@value.eval(context)) rescue @value.eval(context) end end |