Sha256: 42a5ec0a7fc527bd10fe2b00e63871f0d124c59b5d25adae2769321c2961bf4c
Contents?: true
Size: 521 Bytes
Versions: 1
Compression:
Stored size: 521 Bytes
Contents
module SubDiff class Differ < Struct.new(:diff_collection, :diff_method) def diff(*args) # Ruby 1.8.7 does not support additional args after * (splat) block = args.pop differ.call(args.first) do |match| diff = { :match => match, :prefix => $`, :suffix => $' } diff[:replacement] = match.sub(*args, &block) yield(diff_collection, diff) end diff_collection end private def differ diff_collection.string.method(diff_method) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sub_diff-1.0.0 | lib/sub_diff/differ.rb |