Class: Atomizer::Feed
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Feed
constructor
A new instance of Feed.
- #to_xml(xml, root_element = true) ⇒ Object
Methods inherited from FeedItem
feed_attributes, feed_no_collection_group_tag, feed_no_collection_group_tag!, feed_tag_name
Methods included from Buildable
Constructor Details
#initialize ⇒ Feed
Returns a new instance of Feed.
84 85 86 87 88 89 |
# File 'lib/atomizer/feed.rb', line 84 def initialize @authors = [] @contributors = [] @entries = [] @links = [] end |
Class Method Details
.parse(xml) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/atomizer/feed.rb', line 7 def parse(xml) doc = Nokogiri::XML(xml) feed = new feed.id = text(doc, "feed>id") feed.title = text(doc, "feed>title") feed.subtitle = text(doc, "feed>subtitle") feed.updated = parse_time text(doc, "feed>updated") feed.rights = text(doc, "feed>rights") generator = text(doc, "feed>generator") if generator feed.generator = Generator.new(:name => text(doc, "feed>generator"), :uri => attribute_text(doc, "feed>generator", "uri"), :version => attribute_text(doc, "feed>generator", "version")) end feed.links = parse_links(doc.css("feed>link")) doc.css("entry").each do |e| entry = Entry.new entry.id = text(e, "id") entry.title = text(e, "title") entry.content = parse_content e.css("content") entry.updated = parse_time(text(e, "updated")) entry.published = parse_time(text(e, "published")) entry. = e.css("author"), Author entry.contributors = e.css("contributor"), Contributor entry.links = parse_links(e.css("link")) feed.entries << entry end feed end |
Instance Method Details
#to_xml(xml, root_element = true) ⇒ Object
91 92 93 94 95 |
# File 'lib/atomizer/feed.rb', line 91 def to_xml(xml, root_element=true) xml.feed :xmlns => "http://www.w3.org/2005/Atom" do super(xml, false) end end |