Class: Naginata::UI::Shell
- Inherits:
-
Object
- Object
- Naginata::UI::Shell
- Defined in:
- lib/naginata/ui/shell.rb
Constant Summary collapse
- LEVELS =
%w(error warn info debug)
Instance Method Summary collapse
- #debug(msg, newline = nil) ⇒ Object
- #error(msg, newline = nil) ⇒ Object
- #info(msg, newline = nil) ⇒ Object
-
#initialize ⇒ Shell
constructor
A new instance of Shell.
- #level(name = nil) ⇒ Object
- #print_table(array, options = {}) ⇒ Object
- #warn(msg, newline = nil) ⇒ Object
- #yes?(msg) ⇒ Boolean
Constructor Details
#initialize ⇒ Shell
Returns a new instance of Shell.
8 9 10 11 |
# File 'lib/naginata/ui/shell.rb', line 8 def initialize @shell = Thor::Base.shell.new @level = ENV['DEBUG'] ? "debug" : "info" end |
Instance Method Details
#debug(msg, newline = nil) ⇒ Object
25 26 27 |
# File 'lib/naginata/ui/shell.rb', line 25 def debug(msg, newline = nil) tell_me(msg, nil, newline) if level("debug") end |
#error(msg, newline = nil) ⇒ Object
21 22 23 |
# File 'lib/naginata/ui/shell.rb', line 21 def error(msg, newline = nil) tell_me(msg, :red, newline) if level("error") end |
#info(msg, newline = nil) ⇒ Object
13 14 15 |
# File 'lib/naginata/ui/shell.rb', line 13 def info(msg, newline = nil) tell_me(msg, nil, newline) if level("info") end |
#level(name = nil) ⇒ Object
29 30 31 |
# File 'lib/naginata/ui/shell.rb', line 29 def level(name = nil) name ? LEVELS.index(name) <= LEVELS.index(@level) : @level end |
#print_table(array, options = {}) ⇒ Object
37 38 39 |
# File 'lib/naginata/ui/shell.rb', line 37 def print_table(array, = {}) @shell.print_table(array, ) end |
#warn(msg, newline = nil) ⇒ Object
17 18 19 |
# File 'lib/naginata/ui/shell.rb', line 17 def warn(msg, newline = nil) tell_me(msg, :yellow, newline) if level("warn") end |
#yes?(msg) ⇒ Boolean
33 34 35 |
# File 'lib/naginata/ui/shell.rb', line 33 def yes?(msg) @shell.yes?(msg) end |