Class: ConsoleRtm::OutputFormatter
- Inherits:
-
Object
- Object
- ConsoleRtm::OutputFormatter
- Defined in:
- lib/rmilk/output_formatter.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #clean_output! ⇒ Object
- #error(text) ⇒ Object
- #format_history(history) ⇒ Object
- #format_tasks(tasks) ⇒ Object
-
#initialize(complex_formatter = true) ⇒ OutputFormatter
constructor
A new instance of OutputFormatter.
- #output(text) ⇒ Object
Constructor Details
#initialize(complex_formatter = true) ⇒ OutputFormatter
Returns a new instance of OutputFormatter.
6 7 8 9 10 11 |
# File 'lib/rmilk/output_formatter.rb', line 6 def initialize(complex_formatter = true) @complex_formatter = complex_formatter @colors = {:red => "\033[31m", :blue => "\033[34m", :lightBlue => "\033[36m"} end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
4 5 6 |
# File 'lib/rmilk/output_formatter.rb', line 4 def result @result end |
Instance Method Details
#clean_output! ⇒ Object
13 14 15 |
# File 'lib/rmilk/output_formatter.rb', line 13 def clean_output! @result = '' end |
#error(text) ⇒ Object
37 38 39 |
# File 'lib/rmilk/output_formatter.rb', line 37 def error(text) @result = text end |
#format_history(history) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/rmilk/output_formatter.rb', line 29 def format_history(history) temp = [] history.each_with_index do |e, i| temp << "#{i} #{e}" end @result = temp.join("\n") end |
#format_tasks(tasks) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rmilk/output_formatter.rb', line 17 def format_tasks(tasks) temp = [] tasks.each_with_index do |e, i| temp << "#{get_priority_color e}#{i} #{e.text}#{get_end_color}" end if @complex_formatter then @result = "------\n" + temp.join("\n") + "\n------" else @result = temp.join("\n") end end |
#output(text) ⇒ Object
41 42 43 |
# File 'lib/rmilk/output_formatter.rb', line 41 def output(text) @result = text end |