Sha256: 7840fd56fa2982c2ed487637ae38d9b507d0932ca15b79249324992cc88c17aa
Contents?: true
Size: 555 Bytes
Versions: 2
Compression:
Stored size: 555 Bytes
Contents
module SubDiff class Gsub < Sub private def process(_builder, diff, _search) super last_prefix << prefix(diff) << diff[:match] end def last_prefix @last_prefix ||= '' end def prefix(_diff) super.sub(last_prefix, '') end def suffix(_diff, search) suffix = super matcher = suffix_matcher(search) skip_suffix = suffix.send(matcher, search) suffix unless skip_suffix end def suffix_matcher(search) search.is_a?(Regexp) ? :match : :include? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sub_diff-1.1.0 | lib/sub_diff/gsub.rb |
sub_diff-1.0.7 | lib/sub_diff/gsub.rb |