Class: GoogleSpreadsheet::Worksheet
- Inherits:
-
Object
- Object
- GoogleSpreadsheet::Worksheet
- Defined in:
- lib/to_google_spreadsheet.rb
Instance Method Summary collapse
Instance Method Details
#populate(rows) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/to_google_spreadsheet.rb', line 39 def populate(rows) # TODO: Stop looping, put directly into the Google Spreadsheet hash # provided by the Gem # https://github.com/gimite/google-spreadsheet-ruby/blob/master/lib/google_spreadsheet.rb#L693-700 rows.each_with_index do |row, row_nr| get_hash_from_row(row).sort_by { |k,v| k.to_s }.each_with_index do |val, col_nr| self[row_nr + 2, col_nr + 1] = val.last end end end |
#set_header_columns(row) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/to_google_spreadsheet.rb', line 32 def set_header_columns(row) # #sort_by to sort by symbols get_hash_from_row(row).keys.sort_by { |k,v| k.to_s }.each_with_index do |key, col_nr| self[1, col_nr + 1] = humanize(key) end end |