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. = "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
Class Attribute Summary
Element - Inherited
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 |
new_with_value_if_need | If |
to_class_name | Given a |
Instance Attribute Summary
- #feed_version=(value) (also: #rss_version=) writeonly
RootElementMixin - Included
#encoding, #feed_subtype, #feed_type, #feed_version, #output_encoding, #output_encoding=, #standalone, #version |
XMLStyleSheetMixin - Included
Element - Inherited
Instance Method Summary
- #image
- #items
- #rss_version writeonly
- #setup_maker_elements(maker)
- #textinput
- #_attrs private
RootElementMixin - Included
#feed_info, #initialize, #setup_maker, #to_atom, #to_feed, #to_rss, #to_xml, #maker_target, #ns_declarations, #same_feed_type?, #tag, #xmldecl |
XMLStyleSheetMixin - Included
Element - Inherited
SetupMaker - Included
#setup_maker, #maker_target, #not_need_to_call_setup_maker_variables, #setup_maker_attributes, #setup_maker_element, #setup_maker_elements |
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 |
#new_with_value_if_need | If |
#to_class_name | Given a |
Constructor Details
.new(feed_version, version = nil, encoding = nil, standalone = nil) ⇒ Rss
# 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 ]#textinput
[ GitHub ]# File 'lib/rss/0.9.rb', line 84
def textinput if @channel @channel.textInput else nil end end