Class: Gitlab::Diff::Formatters::TextFormatter
Instance Attribute Summary collapse
#base_sha, #head_sha, #ignore_whitespace_change, #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
18
|
# 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]
@ignore_whitespace_change = !!attrs[:ignore_whitespace_change]
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
47
48
49
50
51
52
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 47
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
24
25
26
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 24
def complete?
old_line.present? || new_line.present?
end
|
#key ⇒ Object
20
21
22
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 20
def key
@key ||= super.push(old_line, new_line)
end
|
#line_age ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 33
def line_age
if old_line && new_line
nil
elsif new_line
'new'
else
'old'
end
end
|
#position_type ⇒ Object
43
44
45
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 43
def position_type
"text"
end
|
#to_h ⇒ Object
28
29
30
31
|
# File 'lib/gitlab/diff/formatters/text_formatter.rb', line 28
def to_h
super.merge(old_line: old_line, new_line: new_line, line_range: line_range,
ignore_whitespace_change: ignore_whitespace_change)
end
|