Class: HTMLDiff::Builder

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

Constant Summary collapse

VALID_METHODS =
[:replace, :insert, :delete, :equal]

Instance Method Summary collapse

Constructor Details

#initialize(a, b) ⇒ Builder

Returns a new instance of Builder.



314
315
316
317
318
# File 'lib/diff.rb', line 314

def initialize(a, b)
  @a = a
  @b = b
  @content = []
end

Instance Method Details

#do_op(opcode) ⇒ Object



320
321
322
323
324
325
# File 'lib/diff.rb', line 320

def do_op(opcode)
  @opcode = opcode
  op = @opcode[0]
  VALID_METHODS.include?(op) or raise(NameError, "Invalid opcode #{op}")
  self.method(op).call
end

#resultObject



327
328
329
# File 'lib/diff.rb', line 327

def result
  @content.join('')
end