Class: Panda::Boolean

Inherits:
Expression show all
Defined in:
lib/panda/expressions.rb

Overview

The binary boolean expression node class.

The possible operators are:

  • :& (and)

  • :| (or)

NOTE:

The binary operators are used here because you cannot yet overload ruby’s && and || operators (at least in 1.8).

Instance Attribute Summary

Attributes inherited from Expression

#left, #operator, #right

Instance Method Summary collapse

Methods inherited from Expression

#has_operator?, has_operator?, #inspect, inspector=, #operator_alias, operator_alias_for, operators

Methods inherited from Node

define_operator_builders_for

Constructor Details

#initialize(left, operator, right) ⇒ Boolean

Same precondition as Panda::Expression plus a Panda::SyntaxError is raised if left or right is not an instance of Panda::Expression.



128
129
130
131
132
133
# File 'lib/panda/expressions.rb', line 128

def initialize(left, operator, right)
  unless left.kind_of?(Expression) && right.kind_of?(Expression)
    raise SyntaxError, "Bad operand for #{self.class}: (#{left.inspect}) #{operator} (#{right.inspect})"
  end
  super
end