Class: Diffed::UnifiedDiffParser::LineParser
- Inherits:
-
Object
- Object
- Diffed::UnifiedDiffParser::LineParser
- Defined in:
- lib/parsers/unified.rb
Instance Method Summary collapse
- #increment(left_counter, right_counter) ⇒ Object
-
#initialize(line_text) ⇒ LineParser
constructor
A new instance of LineParser.
- #line(header, left_counter, right_counter) ⇒ Object
Constructor Details
#initialize(line_text) ⇒ LineParser
Returns a new instance of LineParser.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/parsers/unified.rb', line 59 def initialize(line_text) @line_text = line_text if line_text.start_with? "-" @type = :left elsif line_text.start_with? "+" @type = :right else @type = :both end end |
Instance Method Details
#increment(left_counter, right_counter) ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/parsers/unified.rb', line 71 def increment(left_counter, right_counter) case @type when :left [left_counter + 1, right_counter] when :right [left_counter, right_counter + 1] when :both [left_counter + 1, right_counter + 1] end end |