Module: Ego::Printer
- Defined in:
- lib/ego/printer.rb
Overview
Utility methods for writing output with formatting.
Class Method Summary collapse
-
.errs(*message) ⇒ nil
Writes the given message(s) to
$stderr, appending a newline if not already included. -
.puts(*message) ⇒ nil
Writes the given message(s) to
$stdout, appending a newline if not already included.
Instance Method Summary collapse
-
#alert(message, *replacements) ⇒ nil
Write stylized message to
$stderrindicating an error or warning message. -
#debug(message, *replacements) ⇒ nil
Write stylized message to
$stderrindicating a debugging message. -
#emote(message) ⇒ nil
Write stylized message to
$stdoutindicating an emote. -
#say(message, *replacements) ⇒ nil
Write stylized message to
$stdoutindicating speech. -
#verbose? ⇒ false
Whether to print debugging messages.
Class Method Details
.errs(*message) ⇒ nil
Writes the given message(s) to $stderr, appending a newline if not
already included.
94 95 96 |
# File 'lib/ego/printer.rb', line 94 def errs(*) warn(*) end |
.puts(*message) ⇒ nil
Writes the given message(s) to $stdout, appending a newline if not
already included.
85 86 87 |
# File 'lib/ego/printer.rb', line 85 def puts(*) $stdout.puts(*) end |
Instance Method Details
#alert(message, *replacements) ⇒ nil
Write stylized message to $stderr indicating an error or warning
message.
49 50 51 |
# File 'lib/ego/printer.rb', line 49 def alert(, *replacements) errs format(, *replacements).light_red end |
#debug(message, *replacements) ⇒ nil
Write stylized message to $stderr indicating a debugging message.
Plug-ins may use this method to provide extra information when the
--verbose flag is supplied at the command-line.
66 67 68 |
# File 'lib/ego/printer.rb', line 66 def debug(, *replacements) errs format(, *replacements) if verbose? end |
#emote(message) ⇒ nil
Write stylized message to $stdout indicating an emote.
Plug-ins may use this method to indicate what the robot is doing.
34 35 36 |
# File 'lib/ego/printer.rb', line 34 def emote() puts "*#{message}*".magenta end |
#say(message, *replacements) ⇒ nil
Write stylized message to $stdout indicating speech.
20 21 22 |
# File 'lib/ego/printer.rb', line 20 def say(, *replacements) puts format(, *replacements).bold end |
#verbose? ⇒ false
Whether to print debugging messages. Can be overridden by classes that
include Printer.
74 75 76 |
# File 'lib/ego/printer.rb', line 74 def verbose? false end |