Class: Dentaku::AST::Arithmetic

Inherits:
Operation show all
Defined in:
lib/dentaku/ast/arithmetic.rb

Constant Summary collapse

DECIMAL =
/\A-?\d*\.\d+\z/.freeze
INTEGER =
/\A-?\d+\z/.freeze

Instance Attribute Summary

Attributes inherited from Operation

#left, #right

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

#operatorObject

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/dentaku/ast/arithmetic.rb', line 16

def operator
  raise NotImplementedError
end

#typeObject



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