Sha256: 0a97df29c7fdabfbfcb63efec2eac6d7947e48ce3459c60af33bf803977df1bf

Contents?: true

Size: 1.19 KB

Versions: 7133

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module RuboCop
  module AST
    # Common functionality for nodes that are binary operations:
    # `or`, `and` ...
    module BinaryOperatorNode
      # Returns the left hand side node of the binary operation.
      #
      # @return [Node] the left hand side of the binary operation
      def lhs
        node_parts[0]
      end

      # Returns the right hand side node of the binary operation.
      #
      # @return [Node] the right hand side of the binary operation
      def rhs
        node_parts[1]
      end

      # Returns all of the conditions, including nested conditions,
      # of the binary operation.
      #
      # @return [Array<Node>] the left and right hand side of the binary
      # operation and the let and right hand side of any nested binary
      # operators
      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
    end
  end
end

Version data entries

7,133 entries across 7,097 versions & 51 rubygems

Version Path
cybrid_api_organization_ruby-0.123.206 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_id_ruby-0.123.206 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_bank_ruby-0.123.205 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_organization_ruby-0.123.205 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_id_ruby-0.123.205 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_bank_ruby-0.123.204 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_organization_ruby-0.123.204 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_id_ruby-0.123.204 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_organization_ruby-0.123.203 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_bank_ruby-0.123.203 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_id_ruby-0.123.203 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_organization_ruby-0.123.200 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_id_ruby-0.123.200 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_id_ruby-0.123.198 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_organization_ruby-0.123.198 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_id_ruby-0.123.197 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_organization_ruby-0.123.197 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_id_ruby-0.123.196 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_organization_ruby-0.123.196 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb
cybrid_api_id_ruby-0.123.195 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/mixin/binary_operator_node.rb