Class: N::RssBuilder
Overview
Build RSS represenations of ruby object collections. Utilize duck typing to grab the attributes to render. – TODO: add more options here, 1.0/2.0 support and more. ++
Class Method Summary collapse
-
.render_0_9(objects, options = {}) ⇒ Object
(also: render)
Options:.
Class Method Details
.render_0_9(objects, options = {}) ⇒ Object Also known as: render
Options:
:description
-
Description of the Feed
:base
-
Base url of the Feed.
:link
-
Link of the Feed.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nitro/builders/rss.rb', line 30 def render_0_9(objects, = {}) c = { :description => 'Syndication' }.update() c[:base] ||= c[:link] raise "Option ':base' cannot be infered!" unless c[:base] channel = RSS::Rss::Channel.new channel.description = c[:description] channel.link = c[:link] if c[:link] for obj in objects item = RSS::Rss::Channel::Item.new item.title = obj.title if obj.respond_to?(:title) item.description = N::StringUtils.head(obj.body, 256) if obj.respond_to?(:body) item.link = "#{c[:base]}/#{obj.view_uri}" if obj.respond_to?(:view_uri) channel.items << item end rss = RSS::Rss.new '0.9' rss.channel = channel return rss.to_s end |