Sha256: 9c63cd3b23e29e07fe3ef94aefc0f3fe9ac6b0d940f5f994907e1e5f04b456ca
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
module Fed module Feed class Atom < Base def parse feed = @document.css('feed').first @title = feed.css('/title').text @description = feed.css('/subtitle').text @link = feed.css('/link').first.attributes['href'].value @updated = DateTime.parse(feed.css('/updated').text) rescue nil @entries = feed.css('entry').map do |entry| entry_title = entry.css('/title').text entry_summary = entry.css('/summary').text entry_content = entry.css('/content').text entry_published = DateTime.parse(entry.css('/updated').text) rescue nil entry_guid = entry.css('/id').text entry_author = entry.css('/author name').map {|a| a.text}.join(', ') link_elem = entry.css("link[rel='alternate']").first entry_link = if (link_elem && (attribute = link_elem.attributes['href'])) attribute.value else "" end enclosure_elem = item.css("link[rel='enclosure']").first entry_enclosure = if !enclosure_elem.nil? url = enclosure_elem.attributes['href'] ? enclosure_elem.attributes['href'].value : '' content_type = enclosure_elem.attributes['type'] ? enclosure_elem.attributes['type'].value : '' Enclosure.new(url, content_type) else nil end Entry.new(entry_title, entry_link, entry_guid, entry_published, entry_author, entry_summary, entry_content, entry_enclosure) end self end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fed-0.0.4 | lib/fed/feed/atom.rb |
fed-0.0.3 | lib/fed/feed/atom.rb |