class Olelo::PatchParser::ChangeHandler

Public Instance Methods

change!(deletion, insertion) click to toggle source
# File lib/olelo/patch.rb, line 76
def change!(deletion, insertion)
  deletion!(deletion)
  insertion!(insertion)
end
end!() click to toggle source
# File lib/olelo/patch.rb, line 72
def end!
  handle_change
end
line!(line) click to toggle source
# File lib/olelo/patch.rb, line 81
def line!(line)
  ch = line[0..0]
  case ch
  when '@'
    handle_change
    separator!
  when '+'
    handle_change if @deletion && @first == '+'
    @first ||= '+'
    (@insertion ||= '') << line[1..-1] << "\n"
  when '-'
    handle_change if @insertion && @first == '-'
    @first ||= '-'
    (@deletion ||= '') << line[1..-1] << "\n"
  when ' '
    handle_change
    context!(line[1..-1] + "\n")
  end
end

Private Instance Methods

handle_change() click to toggle source
# File lib/olelo/patch.rb, line 103
def handle_change
  if @insertion && @deletion
    change!(@deletion, @insertion)
  elsif @insertion
    insertion!(@insertion)
  elsif @deletion
    deletion!(@deletion)
  end
  @insertion = @deletion = @first = nil
end