Class: Estreet::BinaryExpression

Inherits:
Expression show all
Defined in:
lib/estreet/binary_expression.rb

Direct Known Subclasses

LogicalExpression

Instance Attribute Summary

Attributes inherited from Node

#source_location

Instance Method Summary collapse

Methods inherited from Expression

#[], #call, coerce, #property, #to_expression, #to_statement

Methods inherited from Node

#as_json, #loc, #type

Constructor Details

#initialize(operator, left, right) ⇒ BinaryExpression

Returns a new instance of BinaryExpression.



3
4
5
6
7
8
9
# File 'lib/estreet/binary_expression.rb', line 3

def initialize(operator, left, right)
  Estreet.assert_valid_operator(BINARY_OPERATORS, operator)

  @operator = operator
  @left     = left.to_expression
  @right    = right.to_expression
end

Instance Method Details

#attributesObject



11
12
13
14
15
16
17
# File 'lib/estreet/binary_expression.rb', line 11

def attributes
  super.merge(
    operator: @operator,
    left: @left,
    right: @right
  )
end