Module: RuboCop::Cop::IfNode
- Included in:
- Lint::EndAlignment, Lint::RequireParentheses, StatementModifier, Style::GuardClause, Style::IndentationWidth, Style::MultilineIfThen, Style::Next, Style::ParenthesesAroundCondition, Style::SpaceAfterColon
- Defined in:
- lib/rubocop/cop/mixin/if_node.rb
Overview
Common functionality for checking if nodes.
Instance Method Summary collapse
- #elsif?(node) ⇒ Boolean
- #if_else?(node) ⇒ Boolean
- #modifier_if?(node) ⇒ Boolean
- #ternary_op?(node) ⇒ Boolean
Instance Method Details
#elsif?(node) ⇒ Boolean
15 16 17 18 |
# File 'lib/rubocop/cop/mixin/if_node.rb', line 15 def elsif?(node) node.loc.respond_to?(:keyword) && node.loc.keyword && node.loc.keyword.is?('elsif') end |
#if_else?(node) ⇒ Boolean
20 21 22 |
# File 'lib/rubocop/cop/mixin/if_node.rb', line 20 def if_else?(node) node.loc.respond_to?(:else) && node.loc.else end |
#modifier_if?(node) ⇒ Boolean
7 8 9 |
# File 'lib/rubocop/cop/mixin/if_node.rb', line 7 def modifier_if?(node) node.loc.end.nil? end |
#ternary_op?(node) ⇒ Boolean
11 12 13 |
# File 'lib/rubocop/cop/mixin/if_node.rb', line 11 def ternary_op?(node) node.loc.respond_to?(:question) end |