123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::AST::BinaryOperatorNode

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/rubocop/ast/node/mixin/binary_operator_node.rb

Overview

Common functionality for nodes that are binary operations: or, and …​

Instance Method Summary

Instance Method Details

#conditionsArray<Node>

Returns all of the conditions, including nested conditions, of the binary operation.

operation and the let and right hand side of any nested binary operators

Returns:

  • (Array<Node>)

    the left and right hand side of the binary

[ GitHub ]

  
# File 'lib/rubocop/ast/node/mixin/binary_operator_node.rb', line 28

def conditions
  lhs, rhs = *self
  lhs = lhs.children.first if lhs.begin_type?
  rhs = rhs.children.first if rhs.begin_type?

  [lhs, rhs].each_with_object([]) do |side, collection|
    if side.operator_keyword?
      collection.concat(side.conditions)
    else
      collection << side
    end
  end
end

#lhsNode

Returns the left hand side node of the binary operation.

Returns:

  • (Node)

    the left hand side of the binary operation

[ GitHub ]

  
# File 'lib/rubocop/ast/node/mixin/binary_operator_node.rb', line 11

def lhs
  node_parts[0]
end

#rhsNode

Returns the right hand side node of the binary operation.

Returns:

  • (Node)

    the right hand side of the binary operation

[ GitHub ]

  
# File 'lib/rubocop/ast/node/mixin/binary_operator_node.rb', line 18

def rhs
  node_parts[1]
end