Module: Birdwatcher::Concerns::Outputting
- Included in:
- Birdwatcher::Command, Module
- Defined in:
- lib/birdwatcher/concerns/outputting.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#confirm(question) ⇒ Object
Ask the user for confirmation.
-
#error(message) ⇒ Object
Output an error message to the console.
-
#fatal(message) ⇒ Object
Output a fatal message to the console.
-
#info(message) ⇒ Object
Output an informational message to the console.
-
#line_separator ⇒ Object
Output a line to the console.
-
#newline ⇒ Object
Output a newline to the console.
-
#output(data) ⇒ Object
Output data to the console.
-
#output_formatted(*args) ⇒ Object
Output formatted data to the console.
-
#task(message, fatal = false, &block) ⇒ Object
Output an informational message to the console that reports when a longer-running task is done.
-
#warn(message) ⇒ Object
Output a warning message to the console.
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 4 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#confirm(question) ⇒ Object
Ask the user for confirmation
Waits for the user to answer Yes or No to a question. Useful for making the user confirm destructive actions before executing them.
109 110 111 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 109 def confirm(question) HighLine.agree("#{question} (y/n) ") end |
#error(message) ⇒ Object
Output an error message to the console
Formats the message as an error message
76 77 78 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 76 def error() Birdwatcher::Console.instance.error() end |
#fatal(message) ⇒ Object
Output a fatal message to the console
Formats the message as a fatal message
94 95 96 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 94 def fatal() Birdwatcher::Console.instance.fatal() end |
#info(message) ⇒ Object
Output an informational message to the console
Formats the message as an informational message
52 53 54 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 52 def info() Birdwatcher::Console.instance.info() end |
#line_separator ⇒ Object
Output a line to the console
Used for consistant spacing and separation between console output
43 44 45 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 43 def line_separator Birdwatcher::Console.instance.line_separator end |
#newline ⇒ Object
Output a newline to the console
Used for consistant spacing in console output
36 37 38 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 36 def newline Birdwatcher::Console.instance.newline end |
#output(data) ⇒ Object
17 18 19 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 17 def output(data) Birdwatcher::Console.instance.output(data) end |
#output_formatted(*args) ⇒ Object
Output formatted data to the console
Outputs data with printf
formatting.
29 30 31 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 29 def output_formatted(*args) Birdwatcher::Console.instance.output_formatted(*args) end |
#task(message, fatal = false, &block) ⇒ Object
Output an informational message to the console that reports when a longer-running task is done.
67 68 69 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 67 def task(, fatal = false, &block) Birdwatcher::Console.instance.task(, fatal, &block) end |
#warn(message) ⇒ Object
Output a warning message to the console
Formats the message as a warning message
85 86 87 |
# File 'lib/birdwatcher/concerns/outputting.rb', line 85 def warn() Birdwatcher::Console.instance.warn() end |