Class: Librarian::UI::Shell
- Inherits:
-
Librarian::UI
- Object
- Librarian::UI
- Librarian::UI::Shell
- Defined in:
- lib/librarian/ui.rb
Instance Attribute Summary collapse
-
#debug_line_numbers ⇒ Object
readonly
Returns the value of attribute debug_line_numbers.
-
#shell ⇒ Object
writeonly
Sets the attribute shell.
Instance Method Summary collapse
- #be_quiet! ⇒ Object
- #confirm(message = nil) ⇒ Object
- #debug(message = nil) ⇒ Object
- #debug! ⇒ Object
- #debug_line_numbers! ⇒ Object
- #error(message = nil) ⇒ Object
- #info(message = nil) ⇒ Object
-
#initialize(shell) ⇒ Shell
constructor
A new instance of Shell.
- #warn(message = nil) ⇒ Object
Constructor Details
#initialize(shell) ⇒ Shell
Returns a new instance of Shell.
24 25 26 27 28 29 |
# File 'lib/librarian/ui.rb', line 24 def initialize(shell) @shell = shell @quiet = false @debug = ENV['DEBUG'] @debug_line_numbers = false end |
Instance Attribute Details
#debug_line_numbers ⇒ Object (readonly)
Returns the value of attribute debug_line_numbers.
22 23 24 |
# File 'lib/librarian/ui.rb', line 22 def debug_line_numbers @debug_line_numbers end |
#shell=(value) ⇒ Object (writeonly)
Sets the attribute shell
21 22 23 |
# File 'lib/librarian/ui.rb', line 21 def shell=(value) @shell = value end |
Instance Method Details
#be_quiet! ⇒ Object
51 52 53 |
# File 'lib/librarian/ui.rb', line 51 def be_quiet! @quiet = true end |
#confirm(message = nil) ⇒ Object
39 40 41 |
# File 'lib/librarian/ui.rb', line 39 def confirm( = nil) @shell.say( || yield, :green) if !@quiet end |
#debug(message = nil) ⇒ Object
31 32 33 |
# File 'lib/librarian/ui.rb', line 31 def debug( = nil) @shell.say( || yield) if @debug && !@quiet end |
#debug! ⇒ Object
55 56 57 |
# File 'lib/librarian/ui.rb', line 55 def debug! @debug = true end |
#debug_line_numbers! ⇒ Object
59 60 61 |
# File 'lib/librarian/ui.rb', line 59 def debug_line_numbers! @debug_line_numbers = true end |
#error(message = nil) ⇒ Object
47 48 49 |
# File 'lib/librarian/ui.rb', line 47 def error( = nil) @shell.say( || yield, :red) end |
#info(message = nil) ⇒ Object
35 36 37 |
# File 'lib/librarian/ui.rb', line 35 def info( = nil) @shell.say( || yield) if !@quiet end |
#warn(message = nil) ⇒ Object
43 44 45 |
# File 'lib/librarian/ui.rb', line 43 def warn( = nil) @shell.say( || yield, :yellow) end |