class Contraption::RSSBuilder

Public Class Methods

new(posts) click to toggle source
# File lib/contraption/rss_builder.rb, line 5
def initialize posts
  @posts = posts
end

Public Instance Methods

to_rss() click to toggle source
# File lib/contraption/rss_builder.rb, line 9
def to_rss
  RSS::Maker.make('2.0') do |maker|
    maker.channel.author = '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