Class: Dentaku::AST::Comparator
- Defined in:
- lib/dentaku/ast/comparators.rb
Direct Known Subclasses
Equal, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, NotEqual
Instance Attribute Summary
Attributes inherited from Operation
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Operation
#accept, #dependencies, #display_operator, #initialize, max_param_count, min_param_count, right_associative?
Methods inherited from Node
arity, #dependencies, #name, resolve_class
Constructor Details
This class inherits a constructor from Dentaku::AST::Operation
Class Method Details
.precedence ⇒ Object
6 7 8 |
# File 'lib/dentaku/ast/comparators.rb', line 6 def self.precedence 5 end |
Instance Method Details
#operator ⇒ Object
14 15 16 |
# File 'lib/dentaku/ast/comparators.rb', line 14 def operator raise NotImplementedError end |
#type ⇒ Object
10 11 12 |
# File 'lib/dentaku/ast/comparators.rb', line 10 def type :logical end |
#value(context = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/dentaku/ast/comparators.rb', line 18 def value(context = {}) l = validate_value(cast(left.value(context))) r = validate_value(cast(right.value(context))) l.public_send(operator, r) rescue ::ArgumentError => e raise Dentaku::ArgumentError.for(:incompatible_type, value: r, for: l.class), e. end |