Module: RuboCop::Cop::PercentLiteral
- Included in:
- Style::PercentLiteralDelimiters, Style::UnneededCapitalW
- Defined in:
- lib/rubocop/cop/mixin/percent_literal.rb
Overview
Common functionality for handling percent literals.
Instance Method Summary collapse
- #begin_source(node) ⇒ Object
- #percent_literal?(node) ⇒ Boolean
- #process(node, *types) ⇒ Object
- #type(node) ⇒ Object
Instance Method Details
#begin_source(node) ⇒ Object
16 17 18 |
# File 'lib/rubocop/cop/mixin/percent_literal.rb', line 16 def begin_source(node) node.loc.begin.source if node.loc.respond_to?(:begin) && node.loc.begin end |
#percent_literal?(node) ⇒ Boolean
7 8 9 10 |
# File 'lib/rubocop/cop/mixin/percent_literal.rb', line 7 def percent_literal?(node) return unless (begin_source = begin_source(node)) begin_source.start_with?('%') end |
#process(node, *types) ⇒ Object
12 13 14 |
# File 'lib/rubocop/cop/mixin/percent_literal.rb', line 12 def process(node, *types) on_percent_literal(node, types) if percent_literal?(node) end |
#type(node) ⇒ Object
20 21 22 |
# File 'lib/rubocop/cop/mixin/percent_literal.rb', line 20 def type(node) node.loc.begin.source[0..-2] end |