Class: Urss::Rss
- Inherits:
-
Object
- Object
- Urss::Rss
- Defined in:
- lib/urss/rss.rb
Class Method Summary collapse
-
.build(nokogiri_instance) ⇒ Object
~~~~ Class methods ~~~~.
Class Method Details
.build(nokogiri_instance) ⇒ Object
~~~~ Class methods ~~~~
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/urss/rss.rb', line 6 def self.build(nokogiri_instance) raise Urss::NotANokogiriInstance unless nokogiri_instance.is_a?(Nokogiri::XML::Document) namespace = nokogiri_instance.namespaces["xmlns"] ? "xmlns:" : nil # Factory ["channel", "feed"].each do |root| unless (root_instance = nokogiri_instance.xpath("//#{namespace}#{root}")).empty? rss_object = case root when "channel" Urss::Feed::Rss when "feed" Urss::Feed::Atom end.build(root_instance, namespace, root) rss_object.finalize! return rss_object break end end end |