Class: Html2rss::RssBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/rss_builder.rb,
lib/html2rss/rss_builder/article.rb,
lib/html2rss/rss_builder/channel.rb,
lib/html2rss/rss_builder/enclosure.rb,
lib/html2rss/rss_builder/stylesheet.rb

Overview

Builds an RSS Feed by providing channel, articles and stylesheets.

Defined Under Namespace

Classes: Article, Channel, Enclosure, Stylesheet

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel:, articles:, stylesheets: []) ⇒ RssBuilder

Returns a new instance of RssBuilder.

Parameters:



50
51
52
53
54
# File 'lib/html2rss/rss_builder.rb', line 50

def initialize(channel:, articles:, stylesheets: [])
  @channel = channel
  @articles = articles
  @stylesheets = stylesheets
end

Class Method Details

.add_item(article, item_maker) ⇒ void

This method returns an undefined value.

Parameters:



13
14
15
16
17
18
# File 'lib/html2rss/rss_builder.rb', line 13

def add_item(article, item_maker)
  add_item_string_values(article, item_maker)
  add_item_categories(article, item_maker)
  Enclosure.add(article.enclosure, item_maker)
  add_item_guid(article, item_maker)
end

Instance Method Details

#callRSS::Rss

Returns RSS 2.0 document instance.

Returns:

  • (RSS::Rss)

    RSS 2.0 document instance



57
58
59
60
61
62
63
64
# File 'lib/html2rss/rss_builder.rb', line 57

def call
  RSS::Maker.make('2.0') do |maker|
    Stylesheet.add(maker, stylesheets)

    make_channel(maker.channel)
    make_items(maker)
  end
end