Module: RuboCop::Cop::MatchRange
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
RangeHelp
|
|
Defined in: | lib/rubocop/cop/mixin/match_range.rb |
Overview
Common functionality for obtaining source ranges from regexp matches
Constant Summary
RangeHelp
- Included
Instance Method Summary
-
#each_match_range(range, regex)
private
Return a new
Range
covering the first matching group number for each match ofregex
insiderange
. -
#match_range(range, match)
private
For a
match
insiderange
, return a newRange
covering the match.
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
#each_match_range(range, regex) (private)
Return a new Range
covering the first matching group number for each
match of regex
inside range
# File 'lib/rubocop/cop/mixin/match_range.rb', line 13
def each_match_range(range, regex) range.source.scan(regex) { yield match_range(range, Regexp.last_match) } end
#match_range(range, match) (private)
For a match
inside range
, return a new Range
covering the match
# File 'lib/rubocop/cop/mixin/match_range.rb', line 18
def match_range(range, match) range_between(range.begin_pos + match.begin(1), range.begin_pos + match.end(1)) end