Class: Wlog::MakeCsv
- Inherits:
-
Commandable
- Object
- Commandable
- Wlog::MakeCsv
- Defined in:
- lib/wlog/commands/make_csv.rb
Overview
Instance Attribute Summary collapse
-
#ret ⇒ Object
Returns the value of attribute ret.
Instance Method Summary collapse
-
#execute ⇒ Object
TODO refactor me.
-
#initialize(db) ⇒ MakeCsv
constructor
A new instance of MakeCsv.
Constructor Details
#initialize(db) ⇒ MakeCsv
Returns a new instance of MakeCsv.
10 11 12 |
# File 'lib/wlog/commands/make_csv.rb', line 10 def initialize(db) @db = db end |
Instance Attribute Details
#ret ⇒ Object
Returns the value of attribute ret.
27 28 29 |
# File 'lib/wlog/commands/make_csv.rb', line 27 def ret @ret end |
Instance Method Details
#execute ⇒ Object
TODO refactor me. Because I feel like a horrible piece of code.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/wlog/commands/make_csv.rb', line 15 def execute str = "" LogEntry.find_all(@db).group_by{|el| el.date.strftime("%Y-%m-%d")}.each_pair do |key,value| str.concat("#{value.first.date.strftime("%A")} #{key}\n") value.each do |entry| str.concat(",\"#{Helpers.break_string(entry.description,80)}\"#{$/}") end str.concat($/) end @ret = str end |