Class: SubDiff::Differ
- Inherits:
-
Struct
- Object
- Struct
- SubDiff::Differ
- Defined in:
- lib/sub_diff/differ.rb
Instance Attribute Summary collapse
-
#diff_collection ⇒ Object
Returns the value of attribute diff_collection.
-
#diff_method ⇒ Object
Returns the value of attribute diff_method.
Instance Method Summary collapse
Instance Attribute Details
#diff_collection ⇒ Object
Returns the value of attribute diff_collection
2 3 4 |
# File 'lib/sub_diff/differ.rb', line 2 def diff_collection @diff_collection end |
#diff_method ⇒ Object
Returns the value of attribute diff_method
2 3 4 |
# File 'lib/sub_diff/differ.rb', line 2 def diff_method @diff_method end |
Instance Method Details
#diff(*args) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/sub_diff/differ.rb', line 3 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 |