Class: Roo::Spreadsheet
- Inherits:
-
Object
- Object
- Roo::Spreadsheet
- Defined in:
- lib/roo/spreadsheet.rb
Class Method Summary collapse
Class Method Details
.extension_for(path, options) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/roo/spreadsheet.rb', line 16 def extension_for(path, ) case (extension = .delete(:extension)) when ::Symbol [:file_warning] = :ignore extension when ::String [:file_warning] = :ignore extension.tr('.', '').downcase.to_sym else res = ::File.extname((path =~ ::URI.regexp) ? ::URI.parse(::URI.encode(path)).path : path) res.tr('.', '').downcase.to_sym end end |
.open(path, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/roo/spreadsheet.rb', line 4 def open(path, = {}) path = path.respond_to?(:path) ? path.path : path extension = extension_for(path, ) begin Roo::CLASS_FOR_EXTENSION.fetch(extension).new(path, ) rescue KeyError raise ArgumentError, "Can't detect the type of #{path} - please use the :extension option to declare its type." end end |