Class: Deleted
Overview
a seperate class for deleted chunks (for destinction)
Instance Attribute Summary
Attributes inherited from Chunk
#added, #from, #length, #start, #str, #whitespace
Instance Method Summary collapse
-
#initialize(start, from, string) ⇒ Deleted
constructor
A new instance of Deleted.
- #split_at_org!(pos) ⇒ Object
-
#stop ⇒ Object
no length in the modified file.
- #to_s ⇒ Object
Methods inherited from Chunk
#add?, #includes_copy?, #join_adds, #org_includes?, #org_overlaps?, #org_stop, #overlaps?, #pop, #push, #real_string, #rotate, #rstring, short_string, #squeeze, #subchunk
Constructor Details
#initialize(start, from, string) ⇒ Deleted
Returns a new instance of Deleted.
712 713 714 715 716 717 718 719 |
# File 'lib/merge3.rb', line 712 def initialize start , from , string @start = start @length = string.length @str = string @from = from @whitespace = [] raise "Error nil string =#{start} length=#{length} str=-#{@str}=" if string.nil? end |
Instance Method Details
#split_at_org!(pos) ⇒ Object
725 726 727 728 729 730 731 732 733 734 735 736 |
# File 'lib/merge3.rb', line 725 def split_at_org! pos raise "position not in chunk #{pos} : #{self}" unless org_includes?( pos ) left_length = pos - @from right_length = org_stop - pos right = Deleted.new( @start + left_length , pos , @str[left_length, @length] ) raise "Back to the right drawingboard #{self} , #{right} :#{pos}" if right.length != right_length @str = @str[0, left_length] @length = @str.length raise "Back to the left drawingboard #{self} , #{right} :#{pos} :#{left_length}" if @length != left_length raise "Error nil string =#{start} length=#{length} str=-#{@str}=" if @str.nil? return right end |
#stop ⇒ Object
no length in the modified file
721 722 723 |
# File 'lib/merge3.rb', line 721 def stop # no length in the modified file @start end |
#to_s ⇒ Object
738 739 740 |
# File 'lib/merge3.rb', line 738 def to_s super.to_s + " deleted" end |