Class: Urss::Feed::Atom

Inherits:
Urss::Feed show all
Defined in:
lib/urss/feed/atom.rb

Defined Under Namespace

Classes: Entry

Instance Attribute Summary

Attributes inherited from Urss::Feed

#author, #description, #entries, #title, #updated_at, #url

Class Method Summary collapse

Methods inherited from Urss::Feed

#finalize!, #initialize

Constructor Details

This class inherits a constructor from Urss::Feed

Class Method Details

.build(nokogiri_instance, namespace, root_node) ⇒ Object

~~~~ Class methods ~~~~



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/urss/feed/atom.rb', line 6

def self.build(nokogiri_instance, namespace, root_node)
  raise Urss::NotANokogiriInstance unless nokogiri_instance.is_a?(Nokogiri::XML::NodeSet)
  feed_rss = self.new
  feed_rss.title = nokogiri_instance.xpath("//#{namespace}#{root_node}/title").text
  if (feed_rss.title.nil? || feed_rss.title.empty?)
    feed_rss.title = nokogiri_instance.xpath("//#{namespace}#{root_node}/#{namespace}title").text
  end
  feed_rss.url = nokogiri_instance.xpath("//#{namespace}#{root_node}/#{namespace}link[@rel='self']").attr("href").value
  feed_rss.description = nokogiri_instance.xpath("//#{namespace}#{root_node}/#{namespace}subtitle").text.strip
  feed_rss.updated_at = nokogiri_instance.xpath("//#{namespace}#{root_node}/#{namespace}updated").text
  feed_rss.author = nokogiri_instance.xpath("//#{namespace}#{root_node}/#{namespace}author/#{namespace}name").text
  nokogiri_instance.xpath("//#{namespace}entry").each {|item| feed_rss.entries << Urss::Feed::Atom::Entry.build(item, namespace)}

  feed_rss
end