Class: NcsNavigator::Warehouse::UpdatingShell
- Inherits:
-
Object
- Object
- NcsNavigator::Warehouse::UpdatingShell
- 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
Defined Under Namespace
Classes: Quiet
Instance Method Summary collapse
- #back_up_and_say(backup_count, s) ⇒ Object
- #clear_line_then_say(s) ⇒ Object (also: #clear_line_and_say)
-
#initialize(io) ⇒ UpdatingShell
constructor
A new instance of UpdatingShell.
- #say(*s) ⇒ Object
- #say_line(s) ⇒ Object
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 |