Class: Seashell
- Inherits:
-
Object
- Object
- Seashell
- Defined in:
- lib/seashell.rb
Instance Method Summary collapse
- #_colorize(c, s) ⇒ Object
- #_green(s) ⇒ Object
- #_level ⇒ Object
- #_red(s) ⇒ Object
- #action(s) ⇒ Object
- #done ⇒ Object
- #error ⇒ Object
- #failed ⇒ Object
- #indent ⇒ Object
-
#initialize ⇒ Seashell
constructor
A new instance of Seashell.
- #msg(s) ⇒ Object
- #ok ⇒ Object
- #tick ⇒ Object
- #unindent ⇒ Object
Constructor Details
#initialize ⇒ Seashell
Returns a new instance of Seashell.
2 3 4 |
# File 'lib/seashell.rb', line 2 def initialize @indent = 0 end |
Instance Method Details
#_colorize(c, s) ⇒ Object
51 52 53 |
# File 'lib/seashell.rb', line 51 def _colorize(c, s) "\e[#{c}m#{s}\e[0m" end |
#_green(s) ⇒ Object
55 56 57 |
# File 'lib/seashell.rb', line 55 def _green(s) _colorize(32, s) end |
#_level ⇒ Object
6 7 8 |
# File 'lib/seashell.rb', line 6 def _level " " * @indent end |
#_red(s) ⇒ Object
59 60 61 |
# File 'lib/seashell.rb', line 59 def _red(s) _colorize(31, s) end |
#action(s) ⇒ Object
18 19 20 21 |
# File 'lib/seashell.rb', line 18 def action(s) print _level + s $stdout.flush end |
#done ⇒ Object
36 37 38 39 |
# File 'lib/seashell.rb', line 36 def done print " [" + _green("DONE") + "]\n" $stdout.flush end |
#error ⇒ Object
46 47 48 49 |
# File 'lib/seashell.rb', line 46 def error print " [" + _red("ERROR") + "]\n" $stdout.flush end |
#failed ⇒ Object
41 42 43 44 |
# File 'lib/seashell.rb', line 41 def failed print " [" + _red("FAILED") + "]\n" $stdout.flush end |
#indent ⇒ Object
10 11 12 |
# File 'lib/seashell.rb', line 10 def indent @indent = @indent + 1 end |
#msg(s) ⇒ Object
23 24 25 |
# File 'lib/seashell.rb', line 23 def msg(s) puts _level + s end |
#ok ⇒ Object
31 32 33 34 |
# File 'lib/seashell.rb', line 31 def ok print " [" + _green("OK") + "]\n" $stdout.flush end |
#tick ⇒ Object
27 28 29 |
# File 'lib/seashell.rb', line 27 def tick putc "." end |
#unindent ⇒ Object
14 15 16 |
# File 'lib/seashell.rb', line 14 def unindent @indent = (@indent - 1) unless @indent == 0 end |