Class: RDF::Reader
- Inherits:
-
Object
- Object
- RDF::Reader
- Defined in:
- lib/rdf/reader.rb
Class Method Summary collapse
-
.gzopen(filename, options = {}) {|reader| ... } ⇒ Object
Parses input from the given gzip file name or URL.
Class Method Details
.gzopen(filename, options = {}) {|reader| ... } ⇒ Object
Parses input from the given gzip file name or URL.
any additional options (see #initialize and Format.for)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rdf/reader.rb', line 14 def self.gzopen(filename, = {}, &block) Util::File.open_gzipfile(filename, ) do |file| = .dup [:content_type] ||= file.content_type if file.respond_to?(:content_type) [:file_name] ||= filename reader = self.for([:format] || ) do # Return a sample from the input file sample = file.read(1000) file.rewind sample end if reader reader.new(file, , &block) else raise FormatError, "unknown RDF format: #{.inspect}" end end end |