Class: Gitlab::Diff::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/diff/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, type, index, old_pos, new_pos) ⇒ Line

Returns a new instance of Line


7
8
9
10
# File 'lib/gitlab/diff/line.rb', line 7

def initialize(text, type, index, old_pos, new_pos)
  @text, @type, @index = text, type, index
  @old_pos, @new_pos = old_pos, new_pos
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index


4
5
6
# File 'lib/gitlab/diff/line.rb', line 4

def index
  @index
end

#new_posObject (readonly)

Returns the value of attribute new_pos


4
5
6
# File 'lib/gitlab/diff/line.rb', line 4

def new_pos
  @new_pos
end

#old_posObject (readonly)

Returns the value of attribute old_pos


4
5
6
# File 'lib/gitlab/diff/line.rb', line 4

def old_pos
  @old_pos
end

#textObject

Returns the value of attribute text


5
6
7
# File 'lib/gitlab/diff/line.rb', line 5

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type


4
5
6
# File 'lib/gitlab/diff/line.rb', line 4

def type
  @type
end

Instance Method Details

#added?Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/gitlab/diff/line.rb', line 12

def added?
  type == 'new'
end

#removed?Boolean

Returns:

  • (Boolean)

16
17
18
# File 'lib/gitlab/diff/line.rb', line 16

def removed?
  type == 'old'
end