Class: NcsNavigator::Warehouse::UpdatingShell

Inherits:
Object
  • Object
show all
Defined in:
lib/ncs_navigator/warehouse/updating_shell.rb

Overview

A shell wrapper that allows for (and assists with) terminal programs that update their output using \r and \b.

Direct Known Subclasses

Quiet

Defined Under Namespace

Classes: Quiet

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ UpdatingShell

Returns a new instance of UpdatingShell.



8
9
10
# File 'lib/ncs_navigator/warehouse/updating_shell.rb', line 8

def initialize(io)
  @io = io
end

Instance Method Details

#back_up_and_say(backup_count, s) ⇒ Object



16
17
18
19
# File 'lib/ncs_navigator/warehouse/updating_shell.rb', line 16

def back_up_and_say(backup_count, s)
  say "\b" * backup_count
  say "%#{backup_count}s" % s
end

#clear_line_then_say(s) ⇒ Object Also known as: clear_line_and_say



21
22
23
24
# File 'lib/ncs_navigator/warehouse/updating_shell.rb', line 21

def clear_line_then_say(s)
  say clear_line_chars
  say s
end

#say(*s) ⇒ Object



12
13
14
# File 'lib/ncs_navigator/warehouse/updating_shell.rb', line 12

def say(*s)
  s.each { |e| @io.write(e) }
end

#say_line(s) ⇒ Object



27
28
29
# File 'lib/ncs_navigator/warehouse/updating_shell.rb', line 27

def say_line(s)
  say s, "\n"
end