Advertisement
Guest User

Untitled

a guest
Apr 5th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.67 KB | None | 0 0
  1. def to_csv
  2.     out = "";
  3.     FCSV.generate(:encoding => 'u') out do |csv|
  4.       csv << csv_header
  5.  
  6.       # Write the CSV based on the group/sort
  7.       case sort
  8.       when :user, :project
  9.         time_entries.sort.each do |entryname, entry|
  10.           entry[:logs].each do |e|
  11.             csv << time_entry_to_csv(e)
  12.           end
  13.         end
  14.       when :issue
  15.         time_entries.sort.each do |project, entries|
  16.           entries[:issues].sort {|a,b| a[0].id <=> b[0].id}.each do |issue, time_entries|
  17.             time_entries.each do |e|
  18.               csv << time_entry_to_csv(e)
  19.             end
  20.           end
  21.         end
  22.       end
  23.     end
  24.     out
  25.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement