Module: RuboCop::AST::PredicateOperatorNode

Included in:
AndNode, OrNode
Defined in:
lib/rubocop/ast/node/mixin/predicate_operator_node.rb

Overview

Common functionality for nodes that are predicates: `or`, `and` …

Constant Summary collapse

LOGICAL_AND =
'&&'
SEMANTIC_AND =
'and'
LOGICAL_OR =
'||'
SEMANTIC_OR =
'or'

Instance Method Summary collapse

Instance Method Details

#logical_operator?Boolean

Checks whether this is a logical operator.

Returns:

  • (Boolean)

    whether this is a logical operator


23
24
25
# File 'lib/rubocop/ast/node/mixin/predicate_operator_node.rb', line 23

def logical_operator?
  operator == LOGICAL_AND || operator == LOGICAL_OR
end

#operatorString

Returns the operator as a string.

Returns:


16
17
18
# File 'lib/rubocop/ast/node/mixin/predicate_operator_node.rb', line 16

def operator
  loc.operator.source
end

#semantic_operator?Boolean

Checks whether this is a semantic operator.

Returns:

  • (Boolean)

    whether this is a semantic operator


30
31
32
# File 'lib/rubocop/ast/node/mixin/predicate_operator_node.rb', line 30

def semantic_operator?
  operator == SEMANTIC_AND || operator == SEMANTIC_OR
end