module RuboCop::Cop::MatchRange
Common functionality for obtaining source ranges from regexp matches
Private Instance Methods
Source
# 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
Return a new ‘Range` covering the first matching group number for each match of `regex` inside `range`
Source
# 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
For a ‘match` inside `range`, return a new `Range` covering the match