Class: GitDiff::LineNumberRange

Inherits:
Object
  • Object
show all
Defined in:
lib/git_diff/line_number_range.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start = 0, number_of_lines = 1) ⇒ LineNumberRange

Returns a new instance of LineNumberRange.



11
12
13
14
# File 'lib/git_diff/line_number_range.rb', line 11

def initialize(start = 0, number_of_lines = 1)
  @start = start.to_i
  @number_of_lines = number_of_lines.to_i
end

Instance Attribute Details

#number_of_linesObject (readonly)

Returns the value of attribute number_of_lines.



5
6
7
# File 'lib/git_diff/line_number_range.rb', line 5

def number_of_lines
  @number_of_lines
end

#startObject (readonly)

Returns the value of attribute start.



5
6
7
# File 'lib/git_diff/line_number_range.rb', line 5

def start
  @start
end

Class Method Details

.from_string(string) ⇒ Object



7
8
9
# File 'lib/git_diff/line_number_range.rb', line 7

def self.from_string(string)
  new(*string.split(","))
end

Instance Method Details

#to_s(type) ⇒ Object



16
17
18
# File 'lib/git_diff/line_number_range.rb', line 16

def to_s(type)
  "#{type}#{start},#{number_of_lines}"
end