Class: Diffed::DiffHeaderLine
- Inherits:
-
Object
- Object
- Diffed::DiffHeaderLine
- Defined in:
- lib/diffed.rb
Instance Attribute Summary collapse
-
#line_nums ⇒ Object
readonly
Returns the value of attribute line_nums.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(line) ⇒ DiffHeaderLine
constructor
A new instance of DiffHeaderLine.
Constructor Details
#initialize(line) ⇒ DiffHeaderLine
Returns a new instance of DiffHeaderLine.
143 144 145 146 147 148 149 150 |
# File 'lib/diffed.rb', line 143 def initialize(line) if line =~ /^@@ -(\d+),(\d+) \+(\d+),(\d+) @@/ @text = line @line_nums = {left: {from: $1.to_i, to: $2.to_i}, right: {from: $1.to_i, to: $2.to_i}} else raise "Unparseable header line: #{line}" end end |
Instance Attribute Details
#line_nums ⇒ Object (readonly)
Returns the value of attribute line_nums.
141 142 143 |
# File 'lib/diffed.rb', line 141 def line_nums @line_nums end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
141 142 143 |
# File 'lib/diffed.rb', line 141 def text @text end |
Class Method Details
.is_header?(line) ⇒ Boolean
152 153 154 |
# File 'lib/diffed.rb', line 152 def self.is_header?(line) line.start_with? "@@ " end |