Class: MTP::Podcast::Feed
- Inherits:
-
Object
- Object
- MTP::Podcast::Feed
- Defined in:
- lib/mtp/podcast.rb
Instance Attribute Summary collapse
-
#keep ⇒ Object
Returns the value of attribute keep.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(title, options = {}) ⇒ Feed
constructor
A new instance of Feed.
- #items ⇒ Object
Constructor Details
#initialize(title, options = {}) ⇒ Feed
Returns a new instance of Feed.
28 29 30 31 32 |
# File 'lib/mtp/podcast.rb', line 28 def initialize(title, = {}) @title = title @url = ["url"] || [:url] @keep = ["keep"] || [:keep] end |
Instance Attribute Details
#keep ⇒ Object
Returns the value of attribute keep.
27 28 29 |
# File 'lib/mtp/podcast.rb', line 27 def keep @keep end |
#title ⇒ Object
Returns the value of attribute title.
27 28 29 |
# File 'lib/mtp/podcast.rb', line 27 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
27 28 29 |
# File 'lib/mtp/podcast.rb', line 27 def url @url end |
Instance Method Details
#items ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/mtp/podcast.rb', line 34 def items content = nil open(@url) { |s| content = s.read } parser = Syndication::RSS::Parser.new rss = parser.parse(content) rss.items.select { |i| i.keep = @keep; i.pubdate.to_time > @keep.days.ago } end |