Class: Warg::Console::CursorPosition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCursorPosition

Returns a new instance of CursorPosition.



254
255
256
257
# File 'lib/warg.rb', line 254

def initialize
  @row = 1
  @column = 1
end

Instance Attribute Details

#columnObject

Returns the value of attribute column.



251
252
253
# File 'lib/warg.rb', line 251

def column
  @column
end

#rowObject

Returns the value of attribute row.



252
253
254
# File 'lib/warg.rb', line 252

def row
  @row
end

Instance Method Details

#adjust_to(content) ⇒ Object



259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/warg.rb', line 259

def adjust_to(content)
  last_line_length = content.last_line_length
  newline_count = content.newline_count

  if newline_count > 0
    @column = last_line_length + 1
  else
    @column += last_line_length
  end

  @row += newline_count
end

#inspectObject



272
273
274
# File 'lib/warg.rb', line 272

def inspect
  %{#<#{self.class.name} row=#{row} column=#{column}>}
end