Class: Dentaku::AST::Negation
- Defined in:
- lib/dentaku/ast/negation.rb
Instance Attribute Summary
Attributes inherited from Operation
Class Method Summary collapse
Instance Method Summary collapse
- #dependencies(context = {}) ⇒ Object
-
#initialize(node) ⇒ Negation
constructor
A new instance of Negation.
- #type ⇒ Object
- #value(context = {}) ⇒ Object
Constructor Details
#initialize(node) ⇒ Negation
Returns a new instance of Negation.
4 5 6 7 |
# File 'lib/dentaku/ast/negation.rb', line 4 def initialize(node) @node = node fail ParseError, "Negation requires numeric operand" unless valid_node?(node) end |
Class Method Details
.arity ⇒ Object
17 18 19 |
# File 'lib/dentaku/ast/negation.rb', line 17 def self.arity 1 end |
.precedence ⇒ Object
25 26 27 |
# File 'lib/dentaku/ast/negation.rb', line 25 def self.precedence 40 end |
.right_associative? ⇒ Boolean
21 22 23 |
# File 'lib/dentaku/ast/negation.rb', line 21 def self.right_associative? true end |
Instance Method Details
#dependencies(context = {}) ⇒ Object
29 30 31 |
# File 'lib/dentaku/ast/negation.rb', line 29 def dependencies(context={}) @node.dependencies(context) end |
#type ⇒ Object
13 14 15 |
# File 'lib/dentaku/ast/negation.rb', line 13 def type :numeric end |
#value(context = {}) ⇒ Object
9 10 11 |
# File 'lib/dentaku/ast/negation.rb', line 9 def value(context={}) @node.value(context) * -1 end |