Sha256: 1e01ae7887f3778e137189a8a2a5896956780dd472760f0a84f3a3b9212b9b79
Contents?: true
Size: 721 Bytes
Versions: 6886
Compression:
Stored size: 721 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop # Common functionality for obtaining source ranges from regexp matches module MatchRange include RangeHelp private # Return a new `Range` covering the first matching group number for each # match of `regex` inside `range` def each_match_range(range, regex) range.source.scan(regex) do yield match_range(range, Regexp.last_match) end end # For a `match` inside `range`, return a new `Range` covering the match def match_range(range, match) range_between(range.begin_pos + match.begin(1), range.begin_pos + match.end(1)) end end end end
Version data entries
6,886 entries across 6,860 versions & 30 rubygems