Class: Bundler::LockfileParser::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/lockfile_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, column) ⇒ Position

Returns a new instance of Position.



9
10
11
12
# File 'lib/bundler/lockfile_parser.rb', line 9

def initialize(line, column)
  @line = line
  @column = column
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



8
9
10
# File 'lib/bundler/lockfile_parser.rb', line 8

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



8
9
10
# File 'lib/bundler/lockfile_parser.rb', line 8

def line
  @line
end

Instance Method Details

#advance!(string) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/bundler/lockfile_parser.rb', line 14

def advance!(string)
  lines = string.count("\n")
  if lines > 0
    @line += lines
    @column = string.length - string.rindex("\n")
  else
    @column += string.length
  end
end

#to_sObject



24
25
26
# File 'lib/bundler/lockfile_parser.rb', line 24

def to_s
  "#{line}:#{column}"
end