Class: Feedzirra::Feed
- Inherits:
-
Object
- Object
- Feedzirra::Feed
- Defined in:
- lib/feedzirra/feed.rb
Overview
TODO - remove this class, and only use the Feedzirra::Reader class for accessing feed data.
Class Method Summary collapse
-
.fetch_and_parse(urls, options = {}) ⇒ Object
Fetches and returns the parsed XML for each URL provided.
-
.fetch_raw(urls, options = {}) ⇒ Object
Fetches and returns the raw XML for each URL provided.
-
.update(feeds, options = {}) ⇒ Object
Updates each feed for each Feed object provided.
Class Method Details
.fetch_and_parse(urls, options = {}) ⇒ Object
Fetches and returns the parsed XML for each URL provided.
Parameters
[urls
- :user_agent - String that overrides the default user agent.
- :if_modified_since - Time object representing when the feed was last updated.
- :if_none_match - String, an etag for the request that was stored previously.
- :on_success - Block that gets executed after a successful request.
- :on_failure - Block that gets executed after a failed request.
Returns
A Feed object if a single URL is passed.
A Hash if multiple URL's are passed. The key will be the URL, and the value the Feed object.
20 21 22 23 24 |
# File 'lib/feedzirra/feed.rb', line 20 def self.fetch_and_parse(urls, = {}) multi = Feedzirra::HttpMulti.new(urls, ) multi.perform urls.is_a?(String) ? multi.responses.values.first : multi.responses end |
.fetch_raw(urls, options = {}) ⇒ Object
Fetches and returns the raw XML for each URL provided.
Parameters
[urls
Returns
A String of XML if a single URL is passed.
A Hash if multiple URL's are passed. The key will be the URL, and the value the XML.
FIXME - Raw mode is currently not supported!
61 62 63 64 65 |
# File 'lib/feedzirra/feed.rb', line 61 def self.fetch_raw(urls, = {}) multi = Feedzirra::HttpMulti.new(urls, .merge(:raw => true)) multi.perform urls.is_a?(String) ? multi.responses.values.first : multi.responses end |
.update(feeds, options = {}) ⇒ Object
Updates each feed for each Feed object provided.
Parameters
[feeds
Returns
A updated Feed object if a single URL is passed.
A Hash if multiple Feeds are passed. The key will be the URL, and the value the updated Feed object.
38 39 40 41 42 43 |
# File 'lib/feedzirra/feed.rb', line 38 def self.update(feeds, = {}) multi = Feedzirra::HttpMulti.new(urls, ) multi.perform multi.responses.size == 1 ? multi.responses.values.first : multi.responses.values end |