Class: Gitlab::Diff::Formatters::TextFormatter
Instance Attribute Summary collapse
#base_sha, #file_identifier_hash, #head_sha, #new_path, #old_path, #start_sha
Instance Method Summary
collapse
Constructor Details
Returns a new instance of TextFormatter.
11
12
13
14
15
16
17
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 11
def initialize(attrs)
@old_line = attrs[:old_line]
@new_line = attrs[:new_line]
@line_range = attrs[:line_range]
super(attrs)
end
|
Instance Attribute Details
#line_range ⇒ Object
Returns the value of attribute line_range
9
10
11
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 9
def line_range
@line_range
end
|
#new_line ⇒ Object
Returns the value of attribute new_line
8
9
10
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 8
def new_line
@new_line
end
|
#old_line ⇒ Object
Returns the value of attribute old_line
7
8
9
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 7
def old_line
@old_line
end
|
Instance Method Details
#==(other) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 45
def ==(other)
other.is_a?(self.class) &&
new_line == other.new_line &&
old_line == other.old_line &&
line_range == other.line_range
end
|
#complete? ⇒ Boolean
23
24
25
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 23
def complete?
old_line.present? || new_line.present?
end
|
#key ⇒ Object
19
20
21
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 19
def key
@key ||= super.push(old_line, new_line)
end
|
#line_age ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 31
def line_age
if old_line && new_line
nil
elsif new_line
'new'
else
'old'
end
end
|
#position_type ⇒ Object
41
42
43
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 41
def position_type
"text"
end
|
#to_h ⇒ Object
27
28
29
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 27
def to_h
super.merge(old_line: old_line, new_line: new_line, line_range: line_range)
end
|