Class: Gitlab::WordDiff::Segments::DiffHunk

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/word_diff/segments/diff_hunk.rb

Instance Method Summary collapse

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

Returns:

  • (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_newObject



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_oldObject



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_sObject



34
35
36
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 34

def to_s
  line
end