30 # Every line from the passed in diff gets transformed into an instance of
31 # one of line Line class's subclasses. One subclass exists for each line
32 # type in a diff. As such there is an AddLine class for added lines, a RemLine
33 # class for removed lines, an UnModLine class for lines which remain unchanged and
34 # a SepLine class which represents all the lines that aren't part of the diff.
37 def add(line, line_number)
38 AddLine.new(line, line_number)
41 def rem(line, line_number)
42 RemLine.new(line, line_number)
45 def unmod(line, line_number)
46 UnModLine.new(line, line_number)
54 def initialize(line, line_number)
61 %Q{#<#{self.class.name} [#{number.inspect}] "#{self}">}
66 def initialize(line, line_number)
67 super(line, line_number)
72 def initialize(line, line_number)
73 super(line, line_number)
77 class UnModLine < Line
78 def initialize(line, line_number)
79 super(line, line_number)
84 def initialize(line = '...')
89 class HeaderLine < Line
95 # This class is an array which contains Line objects. Just like Line
96 # classes, several Block classes inherit from Block. If all the lines
97 # in the block are added lines then it is an AddBlock. If all lines
98 # in the block are removed lines then it is a RemBlock. If the lines
99 # in the block are all unmodified then it is an UnMod block. If the
100 # lines in the block are a mixture of added and removed lines then
101 # it is a ModBlock. There are no blocks that contain a mixture of
102 # modified and unmodified lines.
105 def add; AddBlock.new end
106 def rem; RemBlock.new end
107 def mod; ModBlock.new end
108 def unmod; UnModBlock.new end
109 def header; HeaderBlock.new end
114 class AddBlock < Block; end
115 class RemBlock < Block; end
116 class ModBlock < Block; end
117 class UnModBlock < Block; end
118 class SepBlock < Block; end
119 class HeaderBlock < Block; end