Class: Dentaku::AST::Combinator

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

Direct Known Subclasses

And, Or

Instance Attribute Summary

Attributes inherited from Operation

#left, #right

Instance Method Summary collapse

Methods inherited from Operation

#accept, #dependencies, #display_operator, max_param_count, min_param_count, right_associative?

Methods inherited from Node

arity, #dependencies, #name, precedence, resolve_class

Constructor Details

#initializeCombinator

Returns a new instance of Combinator.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dentaku/ast/combinators.rb', line 6

def initialize(*)
  super

  unless valid_node?(left)
    raise NodeError.new(:logical, left.type, :left),
          "#{self.class} requires logical operands"
  end
  unless valid_node?(right)
    raise NodeError.new(:logical, right.type, :right),
          "#{self.class} requires logical operands"
  end
end

Instance Method Details

#typeObject



19
20
21
# File 'lib/dentaku/ast/combinators.rb', line 19

def type
  :logical
end