module RuboCop::Cop::MatchRange
Common functionality for obtaining source ranges from regexp matches
Private Instance Methods
each_match_range(range, regex) { |match_range(range, last_match)| ... }
click to toggle source
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)
click to toggle source
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