Class: SimpleSpreadsheet::Workbook

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-spreadsheet.rb

Class Method Summary collapse

Class Method Details

.read(file, ext = nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/simple-spreadsheet.rb', line 11

def self.read(file, ext = nil)
  file  = file.to_s
  ext ||= File.extname(file).downcase
  case ext
  when '.xls'
    ExcelReader.new(file)
  when '.xlsx'
    ExcelxReader.new(file)
  when '.ods'
    OpenofficeReader.new(file)
  when '.csv'
    CsvReader.new(file)
  when '.csvx'
    CsvxReader.new(file)
  when '.csvt', '.tsv'
    CsvtReader.new(file)
  else
    nil
  end
end