Sha256: f70e123a486bcb3d6e4ce96897c24e72f70639beec421c2207576ede50a85ceb
Contents?: true
Size: 1.64 KB
Versions: 7
Compression:
Stored size: 1.64 KB
Contents
## # Repesents the items published by the firehoser (the feed entries). # They have accessors for the following fields : # - title # - summary # - link # - published # - unique_id # - chunks (long entries might be notified in several chunks) # - chunk (current chunk out of chunks) # require "cgi" class Item include SAXMachine element :item, :as => :chunk, :value => :chunk element :item, :as => :chunks, :value => :chunks element :title element :summary element :link, :as => :link, :value => :href element :id, :as => :unique_id element :published def link CGI.unescape(@link).gsub("\n", "") end def published Time.parse(@published) end def chunks @chunks.to_i end def chunk @chunk.to_i end end ## # Notification : sent every time a feed has been fetched. It has the following methods: # - message_status : a simple message that gives information about the last fetch # - http_status : status of the http response # - feed_url : url of the feed # - next_fetch : Time when the feed will be fetched again (this is purely informative and it might change) # - items : array of new items detected (might be empty) class NotificationStanza include SAXMachine def initialize(xml) parse(xml.to_s) end def next_fetch Time.parse(@next_fetch) end def http_status @http_status.to_i end def feed_url CGI.unescape(@feed_url).gsub("\n", "") end element :http, :as => :message_status element :http, :as => :http_status, :value => :code element :status, :value => :feed, :as => :feed_url element :next_fetch elements :item, :as => :entries, :class => Item end
Version data entries
7 entries across 7 versions & 2 rubygems