Class: Feedcellar::Feed
- Inherits:
-
Object
- Object
- Feedcellar::Feed
- Defined in:
- lib/feedcellar/feed.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(title, link, description, date) ⇒ Feed
constructor
A new instance of Feed.
Constructor Details
#initialize(title, link, description, date) ⇒ Feed
Returns a new instance of Feed.
24 25 26 27 28 29 |
# File 'lib/feedcellar/feed.rb', line 24 def initialize(title, link, description, date) @title = title @link = link @description = description @date = date end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
23 24 25 |
# File 'lib/feedcellar/feed.rb', line 23 def date @date end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
23 24 25 |
# File 'lib/feedcellar/feed.rb', line 23 def description @description end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
23 24 25 |
# File 'lib/feedcellar/feed.rb', line 23 def link @link end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
23 24 25 |
# File 'lib/feedcellar/feed.rb', line 23 def title @title end |
Class Method Details
.parse(feed_url) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/feedcellar/feed.rb', line 31 def self.parse(feed_url) feeds = [] begin rss = Feedjira::Feed.fetch_and_parse(feed_url) rescue $stderr.puts "WARNING: #{$!} (#{feed_url})" return nil end return nil unless rss rss.entries.each do |entry| title = entry.title link = entry.url description = entry.summary || entry.content date = entry.published || entry.updated next unless link feeds << new(title, link, description, date) end feeds end |