Method: Crek::Book#initialize
- Defined in:
- lib/crek/book.rb
#initialize(path, options = {}) ⇒ Book
Returns a new instance of Book.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/crek/book.rb', line 17 def initialize path, = {} check_file_extension = .fetch(:check_file_extension, true) if check_file_extension extension = File.extname([:original_filename] || path).downcase raise 'Not a valid file format.' unless (['.xlsx', '.xlsm'].include? extension) end if [:remote] zipfile = Tempfile.new("file") zipfile.binmode zipfile.write(HTTP.get(path).to_s) zipfile.close path = zipfile.path end @files = Zip::File.open path @shared_strings = SharedStrings.new(self) end |