Class: Gitlab::WordDiff::Segments::DiffHunk
- Inherits:
-
Object
- Object
- Gitlab::WordDiff::Segments::DiffHunk
- Defined in:
- lib/gitlab/word_diff/segments/diff_hunk.rb
Instance Method Summary collapse
- #first_line? ⇒ Boolean
-
#initialize(line) ⇒ DiffHunk
constructor
A new instance of DiffHunk.
- #pos_new ⇒ Object
- #pos_old ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(line) ⇒ DiffHunk
Returns a new instance of DiffHunk.
14 15 16 |
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 14 def initialize(line) @line = line end |
Instance Method Details
#first_line? ⇒ Boolean
30 31 32 |
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 30 def first_line? pos_old <= 1 && pos_new <= 1 end |
#pos_new ⇒ Object
24 25 26 27 28 |
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 24 def pos_new line.match(/\+[0-9]*/)[0].to_i.abs rescue StandardError 0 end |
#pos_old ⇒ Object
18 19 20 21 22 |
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 18 def pos_old line.match(/\-[0-9]*/)[0].to_i.abs rescue StandardError 0 end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 34 def to_s line end |