Class: MediaFeed::Feed
Overview
Mediafeeds handles the retrieval of feed information. The feed attributes are stored in feed attributes, and the individual items are stored in an array of Item objects.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#pubDate ⇒ Object
readonly
Returns the value of attribute pubDate.
-
#thumbnail ⇒ Object
readonly
Returns the value of attribute thumbnail.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#fetch ⇒ Object
fetch the whole media feed.
-
#fetch_since(last_date) ⇒ Object
fetch all entries of the media feed since a certain date (RFC2822 format).
-
#initialize(url) ⇒ Feed
constructor
Feed is initialized with a valid url for the feed itself.
- #to_s ⇒ Object
Constructor Details
#initialize(url) ⇒ Feed
Feed is initialized with a valid url for the feed itself.
50 51 52 53 54 55 |
# File 'lib/media_feed.rb', line 50 def initialize(url) raise ArgumentException if url.nil? raise InvalidUrl if url !~ /(^(http|https):\/\/[a-z0-9]+([-.]{1}[a-z0-9]*)+. [a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix @url = url @entries = nil end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
47 48 49 |
# File 'lib/media_feed.rb', line 47 def description @description end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
47 48 49 |
# File 'lib/media_feed.rb', line 47 def items @items end |
#pubDate ⇒ Object (readonly)
Returns the value of attribute pubDate.
47 48 49 |
# File 'lib/media_feed.rb', line 47 def pubDate @pubDate end |
#thumbnail ⇒ Object (readonly)
Returns the value of attribute thumbnail.
47 48 49 |
# File 'lib/media_feed.rb', line 47 def thumbnail @thumbnail end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
47 48 49 |
# File 'lib/media_feed.rb', line 47 def title @title end |
Instance Method Details
#fetch ⇒ Object
fetch the whole media feed
58 59 60 61 62 |
# File 'lib/media_feed.rb', line 58 def fetch doc = get_feed return nil if doc.nil? parse_feed(doc) end |
#fetch_since(last_date) ⇒ Object
fetch all entries of the media feed since a certain date (RFC2822 format).
65 66 67 68 |
# File 'lib/media_feed.rb', line 65 def fetch_since(last_date) @last_date = parse_date(last_date) fetch end |
#to_s ⇒ Object
70 71 72 73 74 75 |
# File 'lib/media_feed.rb', line 70 def to_s "title #{@title}, description #{@description}" + @items.inject('') do |str,item| str + entry.to_s end end |