Class: Recog::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/recog/formatter.rb

Constant Summary collapse

COLORS =
{
  red: 31,
  yellow: 33,
  green: 32,
  white: 15
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options, output)
  @options = options
  @output  = output || StringIO.new
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/recog/formatter.rb', line 12

def options
  @options
end

#outputObject (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 failure_message(text)
  output.puts color(text, :red)
end

#status_message(text) ⇒ Object



19
20
21
# File 'lib/recog/formatter.rb', line 19

def status_message(text)
  output.puts color(text, :white)
end

#success_message(text) ⇒ Object



23
24
25
# File 'lib/recog/formatter.rb', line 23

def success_message(text)
  output.puts color(text, :green)
end

#warning_message(text) ⇒ Object



27
28
29
# File 'lib/recog/formatter.rb', line 27

def warning_message(text)
  output.puts color(text, :yellow)
end