123456789_123456789_123456789_123456789_123456789_

Class: RSS::Rss

Relationships & Source Files
Namespace Children
Classes:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: RSS::Element
Defined in: lib/rss/2.0.rb,
lib/rss/0.9.rb,
lib/rss/itunes.rb,
lib/rss/trackback.rb,
lib/rss/content/2.0.rb,
lib/rss/dublincore/2.0.rb

Overview

RSS 2.0 support

::RSS has three different versions. This module contains support for version 2.0

Producing RSS 2.0

Producing our own ::RSS feeds is easy as well. Let's make a very basic feed:

require "rss"

rss = RSS::Maker.make("2.0") do |maker|
  maker.channel.language = "en"
  maker.channel.author = "matz"
  maker.channel.updated = Time.now.to_s
  maker.channel.link = "http://www.ruby-lang.org/en/feeds/news.rss"
  maker.channel.title = "Example Feed"
  maker.channel.description = "A longer description of my feed."
  maker.items.new_item do |item|
    item.link = "http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/"
    item.title = "Ruby 1.9.2-p136 is released"
    item.updated = Time.now.to_s
  end
end

puts rss

As you can see, this is a very Builder-like DSL. This code will spit out an ::RSS 2.0 feed with one item. If we needed a second item, we'd make another block with maker.items.new_item and build a second one.

Constant Summary

Element - Inherited

GET_ATTRIBUTES, HAVE_CHILDREN_ELEMENTS, INDENT, MODELS, MUST_CALL_VALIDATORS, NEED_INITIALIZE_VARIABLES, PLURAL_FORMS, TO_ELEMENT_METHODS

RSS09 - Included

ELEMENTS, NSPOOL

Class Attribute Summary

Class Method Summary

Element - Inherited

Utils::InheritedReader - Extended

BaseModel - Extended

Utils - Included

element_initialize_arguments?

This method is used inside of several different objects to determine if special behavior is needed in the constructor.

get_file_and_line_from_caller

Returns an array of two elements: the filename where the calling method is located, and the line number where it is defined.

h,
html_escape

Takes a string s with some HTML in it, and escapes '&', '“', '<' and '>', by replacing them with the appropriate entities.

new_with_value_if_need

If value is an instance of class klass, return it, else create a new instance of klass with value value.

to_class_name

Given a name in a name_with_underscores or a name-with-dashes format, returns the CamelCase version of name.

Instance Attribute Summary

Instance Method Summary

RootElementMixin - Included

XMLStyleSheetMixin - Included

Element - Inherited

SetupMaker - Included

Utils - Included

#element_initialize_arguments?

This method is used inside of several different objects to determine if special behavior is needed in the constructor.

#get_file_and_line_from_caller

Returns an array of two elements: the filename where the calling method is located, and the line number where it is defined.

#h,
#html_escape

Takes a string s with some HTML in it, and escapes '&', '“', '<' and '>', by replacing them with the appropriate entities.

#new_with_value_if_need

If value is an instance of class klass, return it, else create a new instance of klass with value value.

#to_class_name

Given a name in a name_with_underscores or a name-with-dashes format, returns the CamelCase version of name.

Constructor Details

.new(feed_version, version = nil, encoding = nil, standalone = nil) ⇒ Rss

[ GitHub ]

  
# File 'lib/rss/0.9.rb', line 63

def initialize(feed_version, version=nil, encoding=nil, standalone=nil)
  super
  @feed_type = "rss"
end

Instance Attribute Details

#feed_version=(value) (writeonly) Also known as: #rss_version=

[ GitHub ]

  
# File 'lib/rss/0.9.rb', line 59

attr_writer :feed_version

Instance Method Details

#_attrs (private)

[ GitHub ]

  
# File 'lib/rss/0.9.rb', line 102

def _attrs
  [
    ["version", true, "feed_version"],
  ]
end

#image

[ GitHub ]

  
# File 'lib/rss/0.9.rb', line 76

def image
  if @channel
    @channel.image
  else
    nil
  end
end

#items

[ GitHub ]

  
# File 'lib/rss/0.9.rb', line 68

def items
  if @channel
    @channel.items
  else
    []
  end
end

#rss_version (writeonly)

[ GitHub ]

  
# File 'lib/rss/0.9.rb', line 60

alias_method(:rss_version, :feed_version)

#setup_maker_elements(maker)

[ GitHub ]

  
# File 'lib/rss/0.9.rb', line 92

def setup_maker_elements(maker)
  super
  items.each do |item|
    item.setup_maker(maker.items)
  end
  image.setup_maker(maker) if image
  textinput.setup_maker(maker) if textinput
end

#textinput

[ GitHub ]

  
# File 'lib/rss/0.9.rb', line 84

def textinput
  if @channel
    @channel.textInput
  else
    nil
  end
end