Class: TimeCrunch::Conversion
- Inherits:
-
Object
- Object
- TimeCrunch::Conversion
- Defined in:
- lib/time_crunch/conversion.rb
Instance Method Summary collapse
-
#initialize(file_path, employee_map: {}) ⇒ Conversion
constructor
A new instance of Conversion.
- #write_xlsx(file_path) ⇒ Object
Constructor Details
#initialize(file_path, employee_map: {}) ⇒ Conversion
Returns a new instance of Conversion.
3 4 5 |
# 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 |
Instance Method Details
#write_xlsx(file_path) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 |