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.



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

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

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



6
7
8
# File 'lib/bundler/lockfile_parser.rb', line 6

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



6
7
8
# File 'lib/bundler/lockfile_parser.rb', line 6

def line
  @line
end

Instance Method Details

#advance!(string) ⇒ Object



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

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



22
23
24
# File 'lib/bundler/lockfile_parser.rb', line 22

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