Class: Vercon::Stdout

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

Instance Method Summary collapse

Constructor Details

#initializeStdout

Returns a new instance of Stdout.



7
8
9
10
11
# File 'lib/vercon/stdout.rb', line 7

def initialize
  @stdout = $stdout
  @prompt = TTY::Prompt.new
  @lines = 0
end

Instance Method Details

#erase(lines: nil) ⇒ Object



18
19
20
21
22
23
# File 'lib/vercon/stdout.rb', line 18

def erase(lines: nil)
  (lines || @lines).times do
    @stdout.print("\e[A\e[K")
    @lines -= 1
  end
end

#write(message) ⇒ Object



13
14
15
16
# File 'lib/vercon/stdout.rb', line 13

def write(message)
  @stdout.puts(message)
  @lines += message.count("\n") + 1
end