Sha256: 774d8cfce39cd8f4315195e8e4023769465f2ed1492d46fb99f18198eba25465

Contents?: true

Size: 880 Bytes

Versions: 68

Compression:

Stored size: 880 Bytes

Contents

# frozen_string_literal: true

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

      # 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

68 entries across 48 versions & 6 rubygems

Version Path
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/rubocop-ast-0.4.2/lib/rubocop/ast/node/mixin/predicate_operator_node.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/rubocop-ast-0.4.2/lib/rubocop/ast/node/mixin/predicate_operator_node.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/rubocop-ast-0.4.2/lib/rubocop/ast/node/mixin/predicate_operator_node.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/rubocop-ast-0.4.2/lib/rubocop/ast/node/mixin/predicate_operator_node.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/rubocop-ast-0.4.2/lib/rubocop/ast/node/mixin/predicate_operator_node.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/rubocop-ast-0.4.2/lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.6.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.5.1 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.5.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.4.2 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.4.1 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.4.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/ast/node/mixin/predicate_operator_node.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-ast-0.3.0/lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.3.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.2.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.1.0 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/rubocop-ast-0.0.3/lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.0.3 lib/rubocop/ast/node/mixin/predicate_operator_node.rb
rubocop-ast-0.0.2 lib/rubocop/ast/node/mixin/predicate_operator_node.rb