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.



9
10
11
12
# File 'lib/git_diff/line_number_range.rb', line 9

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.



3
4
5
# File 'lib/git_diff/line_number_range.rb', line 3

def number_of_lines
  @number_of_lines
end

#startObject (readonly)

Returns the value of attribute start.



3
4
5
# File 'lib/git_diff/line_number_range.rb', line 3

def start
  @start
end

Class Method Details

.from_string(string) ⇒ Object



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

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

Instance Method Details

#to_s(type) ⇒ Object



14
15
16
# File 'lib/git_diff/line_number_range.rb', line 14

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