Class: Dentaku::AST::Arithmetic
- Defined in:
- lib/dentaku/ast/arithmetic.rb
Direct Known Subclasses
Addition, Division, Exponentiation, Modulo, Multiplication, Negation, Percentage, Subtraction
Constant Summary collapse
- DECIMAL =
/\A-?\d*\.\d+\z/.freeze
- INTEGER =
/\A-?\d+\z/.freeze
Instance Attribute Summary
Attributes inherited from Operation
Instance Method Summary collapse
Methods inherited from Operation
#accept, #dependencies, #display_operator, #initialize, max_param_count, min_param_count, #operator_spacing, right_associative?
Methods inherited from Node
arity, #dependencies, #name, precedence, resolve_class
Constructor Details
This class inherits a constructor from Dentaku::AST::Operation
Instance Method Details
#operator ⇒ Object
16 17 18 |
# File 'lib/dentaku/ast/arithmetic.rb', line 16 def operator raise NotImplementedError end |
#type ⇒ Object
12 13 14 |
# File 'lib/dentaku/ast/arithmetic.rb', line 12 def type :numeric end |
#value(context = {}) ⇒ Object
20 21 22 |
# File 'lib/dentaku/ast/arithmetic.rb', line 20 def value(context = {}) calculate(left.value(context), right.value(context)) end |