Sha256: 3c86f5eab6c72956d36c982d2010109534184adf2339f902b514f40c1c004c93

Contents?: true

Size: 908 Bytes

Versions: 6515

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module AST
    # Common functionality for nodes that are predicates:
    # `or`, `and` ...
    module PredicateOperatorNode
      LOGICAL_AND  = '&&'.freeze
      SEMANTIC_AND = 'and'.freeze
      LOGICAL_OR   = '||'.freeze
      SEMANTIC_OR  = 'or'.freeze

      # Returns the operator as a string.
      #
      # @return [String] the operator
      def operator
        loc.operator.source
      end

      # Checks whether this is a logical operator.
      #
      # @return [Boolean] whether this is a logical operator
      def logical_operator?
        operator == LOGICAL_AND || operator == LOGICAL_OR
      end

      # Checks whether this is a semantic operator.
      #
      # @return [Boolean] whether this is a semantic operator
      def semantic_operator?
        operator == SEMANTIC_AND || operator == SEMANTIC_OR
      end
    end
  end
end

Version data entries

6,515 entries across 6,509 versions & 25 rubygems

Version Path
rubocop-0.57.2 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.57.1 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.57.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.56.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.55.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.54.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.53.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.52.1 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.52.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.51.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.50.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.49.1 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.49.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.48.1 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-0.48.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb