Class: Diff::Combined::Row
- Inherits:
-
Struct
- Object
- Struct
- Diff::Combined::Row
- Defined in:
- lib/diff/combined.rb
Instance Attribute Summary collapse
-
#edits ⇒ Object
Returns the value of attribute edits.
Instance Method Summary collapse
Instance Attribute Details
#edits ⇒ Object
Returns the value of attribute edits
6 7 8 |
# File 'lib/diff/combined.rb', line 6 def edits @edits end |
Instance Method Details
#a_lines ⇒ Object
12 13 14 |
# File 'lib/diff/combined.rb', line 12 def a_lines edits.map { |edit| edit&.a_line } end |
#b_line ⇒ Object
16 17 18 |
# File 'lib/diff/combined.rb', line 16 def b_line edits.first&.b_line end |
#to_s ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/diff/combined.rb', line 20 def to_s symbols = edits.map { |edit| SYMBOLS.fetch(edit&.type, " ") } del = edits.find { |edit| edit&.type == :del } line = del ? del.a_line : edits.first.b_line symbols.join("") + line.text end |
#type ⇒ Object
7 8 9 10 |
# File 'lib/diff/combined.rb', line 7 def type types = edits.compact.map(&:type) types.include?(:ins) ? :ins : types.first end |