Sha256: 55c7b9317c265b044ef16b63c12d8d397c78c64102f470cc873048f74670f502
Contents?: true
Size: 1.77 KB
Versions: 2
Compression:
Stored size: 1.77 KB
Contents
module Superfeedr class Entry < Blather::Stanza::PubSubItem NS = 'http://www.w3.org/2005/Atom'.freeze def self.parse(node) node.find('//ns:event/ns:items/ns2:item', :ns => Blather::Stanza::PubSub::Event.registered_ns, :ns2 => Blather::Stanza::PubSub.registered_ns).map do |item| Entry.new('item').inherit(item) end end def chunks self[:chunks].to_i end def chunk self[:chunk].to_i end def id self.entry.content_from 'ns:id', :ns => NS end def title self.entry.content_from 'ns:title', :ns => NS end def published if published = self.entry.content_from('ns:published', :ns => NS) DateTime.parse published end end def content self.entry.content_from 'ns:content', :ns => NS end def summary self.entry.content_from 'ns:summary', :ns => NS end def categories self.entry.find('ns:category', :ns => NS).map { |cat| cat[:term] } end def links self.entry.find('ns:link', :ns => NS).map { |l| Link.new.inherit(l) } end def authors self.entry.find('ns:author', :ns => NS).map { |l| Author.new.inherit(l) } end def entry Blather::XMPPNode.import(super) end class Link < Blather::XMPPNode def href self[:href] end def rel self[:rel] end def type self[:type] end def title self[:title] end end class Author < Blather::XMPPNode def name self.content_from 'ns:name', :ns => NS end def email self.content_from 'ns:email', :ns => NS end def uri self.content_from 'ns:uri', :ns => NS end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
superfeedr-rb-0.2.0 | lib/superfeedr/entry.rb |
superfeedr-rb-0.1.1 | lib/superfeedr/entry.rb |