Class: AsciiDataTools::Filter::Diffing::Difference
- Inherits:
-
Object
- Object
- AsciiDataTools::Filter::Diffing::Difference
- Defined in:
- lib/ascii-data-tools/filter/diffing.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#left_contents ⇒ Object
readonly
Returns the value of attribute left_contents.
-
#right_contents ⇒ Object
readonly
Returns the value of attribute right_contents.
Instance Method Summary collapse
- #complete? ⇒ Boolean
- #consume(line) ⇒ Object
-
#initialize(left_range, right_range) ⇒ Difference
constructor
A new instance of Difference.
Constructor Details
#initialize(left_range, right_range) ⇒ Difference
Returns a new instance of Difference.
59 60 61 62 63 |
# File 'lib/ascii-data-tools/filter/diffing.rb', line 59 def initialize(left_range, right_range) @left_range, @right_range = left_range, right_range @left_contents, @right_contents = [], [] @consumed_lines = 0 end |
Instance Attribute Details
#left_contents ⇒ Object (readonly)
Returns the value of attribute left_contents.
57 58 59 |
# File 'lib/ascii-data-tools/filter/diffing.rb', line 57 def left_contents @left_contents end |
#right_contents ⇒ Object (readonly)
Returns the value of attribute right_contents.
57 58 59 |
# File 'lib/ascii-data-tools/filter/diffing.rb', line 57 def right_contents @right_contents end |
Instance Method Details
#complete? ⇒ Boolean
65 66 67 |
# File 'lib/ascii-data-tools/filter/diffing.rb', line 65 def complete? @consumed_lines == lines_to_consume end |
#consume(line) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/ascii-data-tools/filter/diffing.rb', line 69 def consume(line) if line =~ /^[<>]/ case line[0..0] when "<" then @left_contents << line[2..-1] when ">" then @right_contents << line[2..-1] end end @consumed_lines += 1 end |