lib/squib/api/data.rb in squib-0.0.4 vs lib/squib/api/data.rb in squib-0.0.5
- old
+ new
@@ -2,17 +2,17 @@
module Squib
# Pulls Excel data from `.xlsx` files into a column-based hash
#
- # Pulls the data into a Hash of arrays based on the columns. First row is assumed to be the header row.
+ # Pulls the data into a Hash of arrays based on the columns. First row is assumed to be the header row.
# See the example `samples/excel.rb` in the [source repository](https://github.com/andymeneely/squib/tree/master/samples)
#
# @example
# # Excel file looks like this:
# # | h1 | h2 |
- # # ------------
+ # # ------------
# # | 1 | 2 |
# # | 3 | 4 |
# data = xlsx file: 'data.xlsx', sheet: 0
# {'h1' => [1,3], 'h2' => [2,4]}
#
@@ -30,23 +30,22 @@
header = s.cell(s.first_row,col).to_s
data[header] = []
(s.first_row+1).upto(s.last_row) do |row|
cell = s.cell(row,col)
# Roo hack for avoiding unnecessary .0's on whole integers
- cell = s.excelx_value(row,col) if s.excelx_type(row,col) == [:numeric_or_formula, "General"]
+ cell = s.excelx_value(row,col) if s.excelx_type(row,col) == [:numeric_or_formula, 'General']
data[header] << cell
end#row
end#col
data
end#xlsx
module_function :xlsx
class Deck
-
+
# Convenience call for Squib.xlsx
def xlsx(opts = {})
Squib.xlsx(opts)
- end
+ end
end
end
-