Class: DiffParser::DiffLine

Inherits:
Object
  • Object
show all
Defined in:
lib/diff_parser/diff_line.rb

Constant Summary collapse

CODE_TYPES =
%w(old new default match)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_line, type, line_new, line_old, idx, sha) ⇒ DiffLine

Returns a new instance of DiffLine.



7
8
9
10
11
12
13
14
# File 'lib/diff_parser/diff_line.rb', line 7

def initialize(raw_line, type, line_new, line_old, idx, sha)
  @raw_line = raw_line
  @line_new = line_new
  @line_old = line_old
  @idx = idx
  @sha = sha
  @type = type
end

Instance Attribute Details

#idxObject (readonly)

Returns the value of attribute idx.



5
6
7
# File 'lib/diff_parser/diff_line.rb', line 5

def idx
  @idx
end

#line_newObject (readonly)

Returns the value of attribute line_new.



5
6
7
# File 'lib/diff_parser/diff_line.rb', line 5

def line_new
  @line_new
end

#line_oldObject (readonly)

Returns the value of attribute line_old.



5
6
7
# File 'lib/diff_parser/diff_line.rb', line 5

def line_old
  @line_old
end

#raw_lineObject (readonly)

Returns the value of attribute raw_line.



5
6
7
# File 'lib/diff_parser/diff_line.rb', line 5

def raw_line
  @raw_line
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/diff_parser/diff_line.rb', line 5

def type
  @type
end

Instance Method Details

#line_codeObject



20
21
22
# File 'lib/diff_parser/diff_line.rb', line 20

def line_code
  "#{sha}_#{line_old}_#{line_new}_#{type}_#{idx}"
end

#line_of_code?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/diff_parser/diff_line.rb', line 16

def line_of_code?
  CODE_TYPES.include?(type)
end