Class: HTMLDiff::Builder
- Inherits:
-
Object
- Object
- HTMLDiff::Builder
- Defined in:
- lib/diff.rb
Constant Summary collapse
- VALID_METHODS =
[:replace, :insert, :delete, :equal]
Instance Method Summary collapse
- #do_op(opcode) ⇒ Object
-
#initialize(a, b) ⇒ Builder
constructor
A new instance of Builder.
- #result ⇒ Object
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 |
#result ⇒ Object
327 328 329 |
# File 'lib/diff.rb', line 327 def result @content.join('') end |