Class: Timetrap::Formatters::Csv

Inherits:
Object
  • Object
show all
Defined in:
lib/timetrap/formatters/csv.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entries) ⇒ Csv

Returns a new instance of Csv.



6
7
8
9
10
11
# File 'lib/timetrap/formatters/csv.rb', line 6

def initialize entries
  @output = entries.inject("start,end,note,sheet\n") do |out, e|
    next(out) unless e.end
    out << %|"#{e.start.strftime(time_format)}","#{e.end.strftime(time_format)}","#{escape(e.note)}","#{e.sheet}"\n|
  end
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



4
5
6
# File 'lib/timetrap/formatters/csv.rb', line 4

def output
  @output
end