Class: Seashell

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

Instance Method Summary collapse

Constructor Details

#initializeSeashell

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

#_levelObject



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

#doneObject



36
37
38
39
# File 'lib/seashell.rb', line 36

def done
    print " [" + _green("DONE") + "]\n"
    $stdout.flush
end

#errorObject



46
47
48
49
# File 'lib/seashell.rb', line 46

def error
    print " [" + _red("ERROR") + "]\n"
    $stdout.flush
end

#failedObject



41
42
43
44
# File 'lib/seashell.rb', line 41

def failed
    print " [" + _red("FAILED") + "]\n"
    $stdout.flush
end

#indentObject



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

#okObject



31
32
33
34
# File 'lib/seashell.rb', line 31

def ok
    print " [" + _green("OK") + "]\n"
    $stdout.flush
end

#tickObject



27
28
29
# File 'lib/seashell.rb', line 27

def tick
    putc "."
end

#unindentObject



14
15
16
# File 'lib/seashell.rb', line 14

def unindent
    @indent = (@indent - 1) unless @indent == 0
end