Module: RSS::RootElementMixin
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
XMLStyleSheetMixin
|
|
Defined in: | lib/rss/rss.rb |
Instance Attribute Summary
- #encoding rw
- #feed_subtype readonly
- #feed_type readonly
- #feed_version readonly
- #output_encoding rw
- #output_encoding=(enc) rw
- #standalone rw
- #version rw
XMLStyleSheetMixin - Included
Instance Method Summary
- #feed_info
- #initialize(feed_version, version = nil, encoding = nil, standalone = nil)
- #setup_maker(maker)
- #to_atom(type, &block)
- #to_feed(type, &block)
- #to_rss(type, &block)
- #to_xml(type = nil, &block)
- #maker_target(target) private
- #ns_declarations private
- #same_feed_type?(type) ⇒ Boolean private
- #tag(indent, attrs = {}, &block) private
- #xmldecl private
XMLStyleSheetMixin - Included
Instance Attribute Details
#encoding (rw)
[ GitHub ]# File 'lib/rss/rss.rb', line 1249
attr_accessor :version, :encoding, :standalone
#feed_subtype (readonly)
[ GitHub ]# File 'lib/rss/rss.rb', line 1248
attr_reader :feed_type, :feed_subtype, :feed_version
#feed_type (readonly)
[ GitHub ]# File 'lib/rss/rss.rb', line 1248
attr_reader :feed_type, :feed_subtype, :feed_version
#feed_version (readonly)
[ GitHub ]# File 'lib/rss/rss.rb', line 1248
attr_reader :feed_type, :feed_subtype, :feed_version
#output_encoding (rw)
[ GitHub ]# File 'lib/rss/rss.rb', line 1247
attr_reader :output_encoding
#output_encoding=(enc) (rw)
[ GitHub ]#standalone (rw)
[ GitHub ]#version (rw)
[ GitHub ]# File 'lib/rss/rss.rb', line 1249
attr_accessor :version, :encoding, :standalone
Instance Method Details
#feed_info
[ GitHub ]# File 'lib/rss/rss.rb', line 1261
def feed_info [@feed_type, @feed_version, @feed_subtype] end
#initialize(feed_version, version = nil, encoding = nil, standalone = nil)
[ GitHub ]# File 'lib/rss/rss.rb', line 1250
def initialize(feed_version, version=nil, encoding=nil, standalone=nil) super() @feed_type = nil @feed_subtype = nil @feed_version = feed_version @version = version || '1.0' @encoding = encoding @standalone = standalone @output_encoding = nil end
#maker_target(target) (private)
[ GitHub ]# File 'lib/rss/rss.rb', line 1342
def maker_target(target) target end
#ns_declarations (private)
[ GitHub ]# File 'lib/rss/rss.rb', line 1333
def ns_declarations decls = {} self.class::NSPOOL.collect do |prefix, uri| prefix = ":#{prefix}" unless prefix.empty? decls["xmlns#{prefix}"] = uri end decls end
#same_feed_type?(type) ⇒ Boolean
(private)
# File 'lib/rss/rss.rb', line 1306
def same_feed_type?(type) if /^(atom|rss)?(\d\.\d)?(?::(.+))?$/i =~ type feed_type = ($1 || @feed_type).downcase feed_version = $2 || @feed_version feed_subtype = $3 || @feed_subtype [feed_type, feed_version, feed_subtype] == feed_info else false end end
#setup_maker(maker)
[ GitHub ]# File 'lib/rss/rss.rb', line 1270
def setup_maker(maker) maker.version = version maker.encoding = encoding maker.standalone = standalone xml_stylesheets.each do |xss| xss.setup_maker(maker) end super end
#tag(indent, attrs = {}, &block) (private)
[ GitHub ]# File 'lib/rss/rss.rb', line 1317
def tag(indent, attrs={}, &block) rv = super(indent, ns_declarations.merge(attrs), &block) return rv if rv.empty? "#{xmldecl}#{xml_stylesheet_pi}#{rv}" end
#to_atom(type, &block)
[ GitHub ]# File 'lib/rss/rss.rb', line 1293
def to_atom(type, &block) to_feed("atom:#{type}", &block) end
#to_feed(type, &block)
[ GitHub ]# File 'lib/rss/rss.rb', line 1282
def to_feed(type, &block) Maker.make(type) do |maker| setup_maker(maker) block.call(maker) if block end end
#to_rss(type, &block)
[ GitHub ]# File 'lib/rss/rss.rb', line 1289
def to_rss(type, &block) to_feed("rss#{type}", &block) end
#to_xml(type = nil, &block)
[ GitHub ]# File 'lib/rss/rss.rb', line 1297
def to_xml(type=nil, &block) if type.nil? or same_feed_type?(type) to_s else to_feed(type, &block).to_s end end
#xmldecl (private)
[ GitHub ]# File 'lib/rss/rss.rb', line 1323
def xmldecl rv = %Q[<?xml version="#{@version}"] if @output_encoding or @encoding rv << %Q[ encoding="#{@output_encoding or @encoding}"] end rv << %Q[ standalone="yes"] if @standalone rv << "?>\n" rv end