Class: Recog::Formatter
- Inherits:
-
Object
- Object
- Recog::Formatter
- Defined in:
- lib/recog/formatter.rb
Constant Summary collapse
- COLORS =
{ red: 31, yellow: 33, green: 32, white: 15 }.freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #failure_message(text) ⇒ Object
-
#initialize(options, output) ⇒ Formatter
constructor
A new instance of Formatter.
- #status_message(text) ⇒ Object
- #success_message(text) ⇒ Object
- #warning_message(text) ⇒ Object
Constructor Details
#initialize(options, output) ⇒ Formatter
Returns a new instance of Formatter.
14 15 16 17 |
# File 'lib/recog/formatter.rb', line 14 def initialize(, output) @options = @output = output || StringIO.new end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/recog/formatter.rb', line 12 def @options end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
12 13 14 |
# File 'lib/recog/formatter.rb', line 12 def output @output end |
Instance Method Details
#failure_message(text) ⇒ Object
31 32 33 |
# File 'lib/recog/formatter.rb', line 31 def (text) output.puts color(text, :red) end |
#status_message(text) ⇒ Object
19 20 21 |
# File 'lib/recog/formatter.rb', line 19 def (text) output.puts color(text, :white) end |
#success_message(text) ⇒ Object
23 24 25 |
# File 'lib/recog/formatter.rb', line 23 def (text) output.puts color(text, :green) end |
#warning_message(text) ⇒ Object
27 28 29 |
# File 'lib/recog/formatter.rb', line 27 def (text) output.puts color(text, :yellow) end |