Class: Ruvi::EditorApp::DiffLogger::RemoveLineChange

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

Instance Attribute Summary collapse

Attributes inherited from Difference

#new_cursor, #old_cursor

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Difference

#correct_cursor_position, #cursor_transition, #finalize, inherited, #initialize, #notify_of_play, #notify_of_unplay, #post_mod_callback, transition_regexp

Constructor Details

This class inherits a constructor from Ruvi::EditorApp::DiffLogger::Difference

Instance Attribute Details

#line_numObject

Returns the value of attribute line_num.



445
446
447
# File 'lib/timemachine.rb', line 445

def line_num
  @line_num
end

#old_line_dataObject

Returns the value of attribute old_line_data.



445
446
447
# File 'lib/timemachine.rb', line 445

def old_line_data
  @old_line_data
end

Class Method Details

.from_s(buf, str) ⇒ Object



450
451
452
453
454
455
456
457
458
# File 'lib/timemachine.rb', line 450

def RemoveLineChange.from_s buf, str
    t = self.new(buf) {
        |t|
        str =~ /^REMOVE:#{transition_regexp}:(.*?):(.*?)$/
        t.old_cursor, t.new_cursor = Point.new($1.to_i, $2.to_i), Point.new($3.to_i, $4.to_i)
        t.line_num, t.old_line_data = $5.to_i, $6
    }
    t
end

.it_was_me(msg) ⇒ Object



459
460
461
# File 'lib/timemachine.rb', line 459

def RemoveLineChange.it_was_me msg
    msg =~ /^REMOVE:/
end

Instance Method Details

#pre_mod_callbackObject



446
447
448
449
# File 'lib/timemachine.rb', line 446

def pre_mod_callback
    super
    @old_line_data = @buffer.lines[@line_num].dup
end

#redoObject



466
467
468
469
# File 'lib/timemachine.rb', line 466

def redo
    @buffer.lines.delete_at @line_num
    super
end

#to_sObject



470
471
472
# File 'lib/timemachine.rb', line 470

def to_s
    "REMOVE:[#{cursor_transition}]:#{@line_num}:#{@old_line_data}"
end

#undoObject



462
463
464
465
# File 'lib/timemachine.rb', line 462

def undo
    @buffer.lines.insert_after @line_num, @old_line_data
    super
end