Class: SubDiff::Differ
- Inherits:
-
Object
- Object
- SubDiff::Differ
- Extended by:
- Forwardable
- Defined in:
- lib/sub_diff/differ.rb
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
Instance Method Summary collapse
- #each_diff(search, *args, block) ⇒ Object
-
#initialize(builder) ⇒ Differ
constructor
A new instance of Differ.
Constructor Details
#initialize(builder) ⇒ Differ
Returns a new instance of Differ.
9 10 11 |
# File 'lib/sub_diff/differ.rb', line 9 def initialize(builder) @builder = builder end |
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
7 8 9 |
# File 'lib/sub_diff/differ.rb', line 7 def builder @builder end |
Instance Method Details
#each_diff(search, *args, block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/sub_diff/differ.rb', line 13 def each_diff(search, *args, block) string.send(diff_method, search) do |match| diff = { match: match, prefix: $`, suffix: $' } diff[:replacement] = match.sub(search, *args, &block) yield(builder, diff) end end |