Module: RuboCop::Cop::PercentLiteral
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
Layout::SpaceInsideArrayPercentLiteral ,
Layout::SpaceInsidePercentLiteralDelimiters ,
Lint::LiteralInInterpolation ,
Lint::NestedPercentLiteral ,
Lint::PercentStringArray ,
Lint::PercentSymbolArray ,
Style::PercentLiteralDelimiters ,
Style::PercentQLiterals ,
Style::RedundantCapitalW ,
Style::RedundantInterpolation
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
RangeHelp
|
|
Defined in: | lib/rubocop/cop/mixin/percent_literal.rb |
Overview
Common functionality for handling percent literals.
Constant Summary
RangeHelp
- Included
Instance Method Summary
- #begin_source(node) private
- #percent_literal?(node) ⇒ Boolean private
- #process(node, *types) private
- #type(node) private
RangeHelp
- Included
#add_range, #column_offset_between, | |
#contents_range | A range containing only the contents of a literal with delimiters (e.g. |
#directions, | |
#effective_column | Returns the column attribute of the range, except if the range is on the first line and there’s a byte order mark at the beginning of that line, in which case 1 is subtracted from the column value. |
#final_pos, #move_pos, #move_pos_str, #range_between, #range_by_whole_lines, #range_with_comments, #range_with_comments_and_lines, #range_with_surrounding_comma, #range_with_surrounding_space, #source_range |
Instance Method Details
#begin_source(node) (private)
[ GitHub ]# File 'lib/rubocop/cop/mixin/percent_literal.rb', line 23
def begin_source(node) node.loc.begin.source if node.loc.respond_to?(:begin) && node.loc.begin end
#percent_literal?(node) ⇒ Boolean
(private)
# File 'lib/rubocop/cop/mixin/percent_literal.rb', line 11
def percent_literal?(node) return false unless (begin_source = begin_source(node)) begin_source.start_with?('%') end
#process(node, *types) (private)
[ GitHub ]# File 'lib/rubocop/cop/mixin/percent_literal.rb', line 17
def process(node, *types) return unless percent_literal?(node) && types.include?(type(node)) on_percent_literal(node) end
#type(node) (private)
[ GitHub ]# File 'lib/rubocop/cop/mixin/percent_literal.rb', line 27
def type(node) node.loc.begin.source[0..-2] end