Method: Ld::Excel#initialize

Defined in:
lib/ld/excel/excel.rb

#initialize(path = nil) ⇒ Excel

Returns a new instance of Excel.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ld/excel/excel.rb', line 7

def initialize path = nil
  if path
    if path.match(/.xls$/)
      if File::exist? path
        @excel = Spreadsheet.open path
        @path = path
      else
        raise "File does not exist:  #{path}"
      end
    else
      raise "Can only read .xls!"
    end
  else
    @excel = Spreadsheet::Workbook.new
  end
end