Class: Runbook::Toolbox
- Inherits:
-
Object
- Object
- Runbook::Toolbox
- Defined in:
- lib/runbook/toolbox.rb
Instance Attribute Summary collapse
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
Instance Method Summary collapse
- #ask(msg, default: nil, echo: true) ⇒ Object
- #error(msg) ⇒ Object
- #exit(return_value) ⇒ Object
- #expand(msg, choices) ⇒ Object
-
#initialize ⇒ Toolbox
constructor
A new instance of Toolbox.
- #output(msg) ⇒ Object
- #warn(msg) ⇒ Object
- #yes?(msg) ⇒ Boolean
Constructor Details
#initialize ⇒ Toolbox
Returns a new instance of Toolbox.
5 6 7 |
# File 'lib/runbook/toolbox.rb', line 5 def initialize @prompt = TTY::Prompt.new end |
Instance Attribute Details
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
3 4 5 |
# File 'lib/runbook/toolbox.rb', line 3 def prompt @prompt end |
Instance Method Details
#ask(msg, default: nil, echo: true) ⇒ Object
9 10 11 |
# File 'lib/runbook/toolbox.rb', line 9 def ask(msg, default: nil, echo: true) prompt.ask(msg, default: default, echo: echo) end |
#error(msg) ⇒ Object
29 30 31 |
# File 'lib/runbook/toolbox.rb', line 29 def error(msg) prompt.error(msg) end |
#exit(return_value) ⇒ Object
33 34 35 |
# File 'lib/runbook/toolbox.rb', line 33 def exit(return_value) super(return_value) end |
#expand(msg, choices) ⇒ Object
13 14 15 |
# File 'lib/runbook/toolbox.rb', line 13 def (msg, choices) prompt.(msg, choices) end |
#output(msg) ⇒ Object
21 22 23 |
# File 'lib/runbook/toolbox.rb', line 21 def output(msg) prompt.say(msg) end |
#warn(msg) ⇒ Object
25 26 27 |
# File 'lib/runbook/toolbox.rb', line 25 def warn(msg) prompt.warn(msg) end |
#yes?(msg) ⇒ Boolean
17 18 19 |
# File 'lib/runbook/toolbox.rb', line 17 def yes?(msg) prompt.yes?(msg) end |