Class: SubDiff::Builder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sub_diff/builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Performs a Sub or Gsub replacement and returns the resulting Collection of Diff objects.

Used internally by CoreExt::String#sub_diff and CoreExt::String#gsub_diff.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, diff_method) ⇒ Builder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Builder


11
12
13
14
# File 'lib/sub_diff/builder.rb', line 11

def initialize(string, diff_method)
  @string = string
  @diff_method = diff_method
end

Instance Attribute Details

#diff_methodObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


9
10
11
# File 'lib/sub_diff/builder.rb', line 9

def diff_method
  @diff_method
end

#stringObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


9
10
11
# File 'lib/sub_diff/builder.rb', line 9

def string
  @string
end

Instance Method Details

#diff(*args, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


16
17
18
19
20
# File 'lib/sub_diff/builder.rb', line 16

def diff(*args, &block)
  build_diff_collection do
    adapter.diff(*args, &block)
  end
end

#push(*args) ⇒ Object Also known as: <<

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


22
23
24
25
26
27
# File 'lib/sub_diff/builder.rb', line 22

def push(*args)
  if args.compact.any?
    diff = Diff.new(*args)
    collection.push(diff)
  end
end