Class: Code::Node::Negation
- Inherits:
-
Code::Node
- Object
- Code::Node
- Code::Node::Negation
- Defined in:
- lib/code/node/negation.rb
Constant Summary collapse
- EXCLAMATION_POINT =
"!"- PLUS =
"+"
Instance Method Summary collapse
- #evaluate(**args) ⇒ Object
-
#initialize(negation) ⇒ Negation
constructor
A new instance of Negation.
Constructor Details
Instance Method Details
#evaluate(**args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/code/node/negation.rb', line 12 def evaluate(**args) object = @statement.evaluate(**args) if operator == EXCLAMATION_POINT if object.truthy? ::Code::Object::Boolean.new(false) else ::Code::Object::Boolean.new(true) end elsif operator == PLUS object else raise NotImplementedError.new(operator) end end |