Class: Wlog::MakeCsv

Inherits:
Commandable show all
Defined in:
lib/wlog/commands/make_csv.rb

Overview

Author:

  • Simon Symeonidis

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#retObject

Returns the value of attribute ret.



23
24
25
# File 'lib/wlog/commands/make_csv.rb', line 23

def ret
  @ret
end

Instance Method Details

#executeObject

TODO refactor me. Because I feel like a horrible piece of code.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wlog/commands/make_csv.rb', line 11

def execute
  str = ""
  LogEntry.all.group_by{|el| el.created_at.strftime("%Y-%m-%d")}.each_pair do |key,value|
    str.concat("#{value.first.created_at.strftime("%A")} #{key}\n")
    value.each do |entry|
      str.concat(",\"#{Helpers.break_string(entry.description,80)}\"#{$/}")
    end
    str.concat($/)
  end
  @ret = str
end