Class: Murlsh::RssBody

Inherits:
Object
  • Object
show all
Includes:
FeedBody
Defined in:
lib/murlsh/rss_body.rb

Overview

Rss feed builder.

Instance Attribute Summary

Attributes included from FeedBody

#config, #feed_url, #req, #updated, #urls

Instance Method Summary collapse

Methods included from FeedBody

#each, #feed_title, #initialize

Instance Method Details

#buildObject

Rss feed builder.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/murlsh/rss_body.rb', line 12

def build
  if defined?(@body)
    @body
  else
    feed = RSS::Maker.make('2.0') do |f|
      f.channel.title = f.channel.description = feed_title
      f.channel.link = feed_url

      f.items.do_sort = true

      urls.each do |mu|
        Murlsh::Plugin.hooks('url_display_pre') do |p|
          p.run mu, req, config
        end

        i = f.items.new_item
        i.title = mu.title_stripped
        i.link = mu.url
        i.date = mu.time

        mu.enclosures.first(1).each do |e|
          i.enclosure.url = e.enclosure_url
          i.enclosure.type = e.content_type
          i.enclosure.length = e.content_length
        end

      end
    end

    @body = feed
  end
end