Class: Stendhal::Reporter

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/stendhal/reporter.rb

Constant Summary collapse

COLORS =
{"black" => "30",
"red" => "31",
"green" => "32",
"yellow" => "33",
"blue" => "34",
"magenta" => "35",
"cyan" => "36",
"white" => "37",

"RED" => "41",
"GREEN" => "42",
"YELLOW" => "43",
"BLUE" => "44",
"MAGENTA" => "45",
"CYAN" => "46",
"WHITE" => "47"}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



7
8
9
10
# File 'lib/stendhal/reporter.rb', line 7

def initialize
  @current_indentation = 0 
  @output = $stdout
end

Instance Attribute Details

#current_indentationObject

Returns the value of attribute current_indentation.



13
14
15
# File 'lib/stendhal/reporter.rb', line 13

def current_indentation
  @current_indentation
end

#output=(value) ⇒ Object (writeonly)

Sets the attribute output

Parameters:

  • value

    the value to set the attribute output to.



12
13
14
# File 'lib/stendhal/reporter.rb', line 12

def output=(value)
  @output = value
end

Class Method Details

.method_missing(*args, &block) ⇒ Object



55
56
57
# File 'lib/stendhal/reporter.rb', line 55

def method_missing(*args, &block)
  instance.send(*args, &block)
end

Instance Method Details

#line(text, options = {}) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/stendhal/reporter.rb', line 37

def line(text, options = {})
  options[:indent].times { tab } if options[:indent]
  with_color(options[:color]) do
    @output.print text
  end
  @output.print "\n"
end

#resetObject



33
34
35
# File 'lib/stendhal/reporter.rb', line 33

def reset
  @output = $stdout
end

#tabObject



49
50
51
# File 'lib/stendhal/reporter.rb', line 49

def tab
  @output.print "  "
end

#whitespaceObject



45
46
47
# File 'lib/stendhal/reporter.rb', line 45

def whitespace
  @output.print "\n"
end