Class: IO::Line::Multiple

Inherits:
Object
  • Object
show all
Defined in:
lib/io/line/multiple.rb

Instance Method Summary collapse

Constructor Details

#initialize(lines, cursor) ⇒ Multiple

Returns a new instance of Multiple.



4
5
6
7
# File 'lib/io/line/multiple.rb', line 4

def initialize(lines, cursor)
  @lines = lines
  @cursor = cursor
end

Instance Method Details



9
10
11
12
13
14
15
16
17
18
# File 'lib/io/line/multiple.rb', line 9

def print(*strs, lineno:)
  line = @lines[lineno]
  if lineno > @cursor
    line.io.cursor_down(lineno - @cursor)
  elsif lineno < @cursor
    line.io.cursor_up(lineno + @cursor)
  end
  @cursor = lineno
  line.rewind.print(*strs)
end