Class: Contraption::RSSBuilder
- Inherits:
-
Object
- Object
- Contraption::RSSBuilder
- Defined in:
- lib/contraption/rss_builder.rb
Instance Method Summary collapse
-
#initialize(posts) ⇒ RSSBuilder
constructor
A new instance of RSSBuilder.
- #to_rss ⇒ Object
Constructor Details
#initialize(posts) ⇒ RSSBuilder
Returns a new instance of RSSBuilder.
5 6 7 |
# File 'lib/contraption/rss_builder.rb', line 5 def initialize posts @posts = posts end |
Instance Method Details
#to_rss ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/contraption/rss_builder.rb', line 9 def to_rss RSS::Maker.make('2.0') do |maker| maker.channel. = 'Casey Robinson' maker.channel.updated = Time.now.to_s maker.channel.link = 'http://rampantmonkey.com/rss' maker.channel.title = 'Rampant Monkey - Everything' maker.channel.description = 'Everything published on rampantmonkey.com' @posts.most_recent(-1).each do |post| maker.items.new_item do |item| item.link = "http://rampantmonkey.com/#{post.publication_date.strftime('%Y/%m')}/#{post.filename('.html')}" item.title = post.title item.pubDate = post.publication_date.to_s item.updated = post.publication_date.to_s item.description = post.summary item.content_encoded = post.body end end end end |