Class: Janeway::AST::BinaryOperator
- Inherits:
-
Expression
- Object
- Expression
- Janeway::AST::BinaryOperator
- Defined in:
- lib/janeway/ast/binary_operator.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
Returns the value of attribute left.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#right ⇒ Object
Returns the value of attribute right.
Attributes inherited from Expression
Instance Method Summary collapse
-
#initialize(operator, left = nil, right = nil) ⇒ BinaryOperator
constructor
A new instance of BinaryOperator.
- #to_s ⇒ Object
Methods inherited from Expression
#indented, #literal?, #singular_query?, #type
Constructor Details
#initialize(operator, left = nil, right = nil) ⇒ BinaryOperator
Returns a new instance of BinaryOperator.
8 9 10 11 12 13 14 15 |
# File 'lib/janeway/ast/binary_operator.rb', line 8 def initialize(operator, left = nil, right = nil) super(nil) raise ArgumentError, "expect symbol, got #{operator.inspect}" unless operator.is_a?(Symbol) @operator = operator self.left = left if left self.right = right if right end |
Instance Attribute Details
#left ⇒ Object
Returns the value of attribute left.
6 7 8 |
# File 'lib/janeway/ast/binary_operator.rb', line 6 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
6 7 8 |
# File 'lib/janeway/ast/binary_operator.rb', line 6 def operator @operator end |
#right ⇒ Object
Returns the value of attribute right.
6 7 8 |
# File 'lib/janeway/ast/binary_operator.rb', line 6 def right @right end |
Instance Method Details
#to_s ⇒ Object
50 51 52 53 |
# File 'lib/janeway/ast/binary_operator.rb', line 50 def to_s # Make precedence explicit by adding parentheses "(#{@left} #{operator_to_s} #{@right})" end |