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)

26
27
28
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 26

def first_line?
  pos_old <= 1 && pos_new <= 1
end

#pos_newObject


22
23
24
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 22

def pos_new
  line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
end

#pos_oldObject


18
19
20
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 18

def pos_old
  line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
end

#to_sObject


30
31
32
# File 'lib/gitlab/word_diff/segments/diff_hunk.rb', line 30

def to_s
  line
end