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
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, output) ⇒ Formatter

Returns a new instance of Formatter.



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

def initialize(options, output)
  @options = options
  @output  = output || StringIO.new
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/recog/formatter.rb', line 10

def options
  @options
end

#outputObject (readonly)

Returns the value of attribute output.



10
11
12
# File 'lib/recog/formatter.rb', line 10

def output
  @output
end

Instance Method Details

#failure_message(text) ⇒ Object



29
30
31
# File 'lib/recog/formatter.rb', line 29

def failure_message(text)
  output.puts color(text, :red)
end

#status_message(text) ⇒ Object



17
18
19
# File 'lib/recog/formatter.rb', line 17

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

#success_message(text) ⇒ Object



21
22
23
# File 'lib/recog/formatter.rb', line 21

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

#warning_message(text) ⇒ Object



25
26
27
# File 'lib/recog/formatter.rb', line 25

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