Class: S3crets::Shell
- Inherits:
-
Object
- Object
- S3crets::Shell
- Defined in:
- lib/s3crets/ui.rb
Overview
Prints messages out to stdout
Instance Attribute Summary collapse
-
#shell ⇒ Object
writeonly
Sets the attribute shell.
Instance Method Summary collapse
- #be_quiet! ⇒ Object
- #confirm(message = nil) ⇒ Object
- #debug(message = nil) ⇒ Object
- #debug! ⇒ 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.
8 9 10 11 12 |
# File 'lib/s3crets/ui.rb', line 8 def initialize(shell) @shell = shell @quiet = false @debug = ENV['DEBUG'] end |
Instance Attribute Details
#shell=(value) ⇒ Object (writeonly)
Sets the attribute shell
6 7 8 |
# File 'lib/s3crets/ui.rb', line 6 def shell=(value) @shell = value end |
Instance Method Details
#be_quiet! ⇒ Object
34 35 36 |
# File 'lib/s3crets/ui.rb', line 34 def be_quiet! @quiet = true end |
#confirm(message = nil) ⇒ Object
22 23 24 |
# File 'lib/s3crets/ui.rb', line 22 def confirm( = nil) @shell.say( || yield, :green) unless @quiet end |
#debug(message = nil) ⇒ Object
14 15 16 |
# File 'lib/s3crets/ui.rb', line 14 def debug( = nil) @shell.say( || yield) if @debug && !@quiet end |
#debug! ⇒ Object
38 39 40 |
# File 'lib/s3crets/ui.rb', line 38 def debug! @debug = true end |
#error(message = nil) ⇒ Object
30 31 32 |
# File 'lib/s3crets/ui.rb', line 30 def error( = nil) @shell.say( || yield, :red) end |
#info(message = nil) ⇒ Object
18 19 20 |
# File 'lib/s3crets/ui.rb', line 18 def info( = nil) @shell.say( || yield) unless @quiet end |
#warn(message = nil) ⇒ Object
26 27 28 |
# File 'lib/s3crets/ui.rb', line 26 def warn( = nil) @shell.say( || yield, :yellow) end |