class TimeCrunch::Conversion

Public Class Methods

new(file_path, employee_map: {}) click to toggle source
# File lib/time_crunch/conversion.rb, line 3
def initialize(file_path, employee_map: {})
  @time_entries = CSV.read(file_path).collect { |row| TimeEntry.new(row, employee_map) }.sort
end

Public Instance Methods

write_xlsx(file_path) click to toggle source
# File lib/time_crunch/conversion.rb, line 7
def write_xlsx(file_path)
  workbook = RubyXL::Workbook.new
  summary_sheet = workbook['Sheet1']
  summary_sheet.sheet_name = 'Summary'
  # TODO: Add data to summary

  entries_sheet = workbook.add_worksheet('Time Entries')
  @time_entries.each_with_index do |time_entry, i|
    3.times do |j|
      entries_sheet.add_cell(i, j, time_entry.value_by_index(j))
    end
  end

  workbook.write(file_path)
end