Class: Stendhal::Reporter
- 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
-
#current_indentation ⇒ Object
Returns the value of attribute current_indentation.
-
#output ⇒ Object
writeonly
Sets the attribute output.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Reporter
constructor
A new instance of Reporter.
- #line(text, options = {}) ⇒ Object
- #reset ⇒ Object
- #tab ⇒ Object
- #whitespace ⇒ Object
Constructor Details
#initialize ⇒ Reporter
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_indentation ⇒ Object
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
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, = {}) [:indent].times { tab } if [:indent] with_color([:color]) do @output.print text end @output.print "\n" end |
#reset ⇒ Object
33 34 35 |
# File 'lib/stendhal/reporter.rb', line 33 def reset @output = $stdout end |
#tab ⇒ Object
49 50 51 |
# File 'lib/stendhal/reporter.rb', line 49 def tab @output.print " " end |
#whitespace ⇒ Object
45 46 47 |
# File 'lib/stendhal/reporter.rb', line 45 def whitespace @output.print "\n" end |