Class: OPDS::OPDSParser
Overview
Class in charge of discovering the type of the given text stream. It will dispatch the pre-parsed atom content to the desired class
Instance Attribute Summary collapse
-
#options ⇒ Hash
Parsing options.
-
#sniffed_type ⇒ Symbol
readonly
Last parsed stream sniffed type (:acquisition,:navigation,:entry).
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ OPDSParser
constructor
A new instance of OPDSParser.
-
#parse(content, browser = nil) ⇒ NavigationFeed, ...
Parse a text stream.
Methods included from Logging
Constructor Details
#initialize(opts = {}) ⇒ OPDSParser
Returns a new instance of OPDSParser.
14 15 16 17 |
# File 'lib/opds/parser.rb', line 14 def initialize(opts={}) @sniffed_type=nil self.=opts.merge({}) end |
Instance Attribute Details
#options ⇒ Hash
Returns parsing options.
11 12 13 |
# File 'lib/opds/parser.rb', line 11 def @options end |
#sniffed_type ⇒ Symbol (readonly)
Returns last parsed stream sniffed type (:acquisition,:navigation,:entry).
13 14 15 |
# File 'lib/opds/parser.rb', line 13 def sniffed_type @sniffed_type end |
Instance Method Details
#parse(content, browser = nil) ⇒ NavigationFeed, ...
Parse a text stream
23 24 25 26 27 28 29 30 31 |
# File 'lib/opds/parser.rb', line 23 def parse(content,browser=nil) @ret=Nokogiri::XML(content) @sniffed_type=sniff(@ret) case @sniffed_type when :acquisition then return OPDS::AcquisitionFeed.from_nokogiri(@ret,browser) when :navigation then return OPDS::NavigationFeed.from_nokogiri(@ret,browser) when :entry then return OPDS::Entry.from_nokogiri(@ret,nil,browser) end end |