Class: Fed::Feed::Rss1
Instance Attribute Summary
Attributes inherited from Base
#description, #document, #entries, #guid, #link, #title, #updated
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Fed::Feed::Base
Instance Method Details
#parse ⇒ Object
4 5 6 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 36 37 |
# File 'lib/fed/feed/rss1.rb', line 4 def parse channel = @document.xpath('/rdf:RDF').css('channel').first @title = channel.css('/title').text @description = channel.css('/description').text @link = channel.css('/link').text @updated = DateTime.parse(channel.css('/pubDate').text) rescue nil entry_list = @document.at('channel items').xpath('rdf:Seq/rdf:li').map {|e| e.attributes['resource'].value } @entries = entry_list.map {|i| @document.css("item[rdf|about='#{i}']")} @entries.map! do |item| item_title = item.css('/title').text item_summary = item.css('/description').text item_content = item.css('/description').text item_link = item.css('/link').text item_published = DateTime.parse(item.css('/pubDate').text) rescue nil item_guid = item.css('/guid').text = item.css('/author').text enclosure_elem = item.css('/enclosure').first item_enclosure = if !enclosure_elem.nil? url = enclosure_elem.attributes['url'] ? enclosure_elem.attributes['url'].value : '' content_type = enclosure_elem.attributes['type'] ? enclosure_elem.attributes['type'].value : '' Enclosure.new(url, content_type) else nil end Entry.new(item_title, item_link, item_guid, item_published, , item_summary, item_content, item_enclosure) end self end |