Module: RSS::RootElementMixin

Includes:
XMLStyleSheetMixin
Included in:
Atom::Entry, Atom::Feed, RDF, Rss
Defined in:
lib/rss/rss.rb

Instance Attribute Summary collapse

Attributes included from XMLStyleSheetMixin

#xml_stylesheets

Instance Method Summary collapse

Instance Attribute Details

#encodingObject

Returns the value of attribute encoding.



1215
1216
1217
# File 'lib/rss/rss.rb', line 1215

def encoding
  @encoding
end

#feed_subtypeObject (readonly)

Returns the value of attribute feed_subtype.



1214
1215
1216
# File 'lib/rss/rss.rb', line 1214

def feed_subtype
  @feed_subtype
end

#feed_typeObject (readonly)

Returns the value of attribute feed_type.



1214
1215
1216
# File 'lib/rss/rss.rb', line 1214

def feed_type
  @feed_type
end

#feed_versionObject (readonly)

Returns the value of attribute feed_version.



1214
1215
1216
# File 'lib/rss/rss.rb', line 1214

def feed_version
  @feed_version
end

#output_encodingObject

Returns the value of attribute output_encoding.



1213
1214
1215
# File 'lib/rss/rss.rb', line 1213

def output_encoding
  @output_encoding
end

#standaloneObject

Returns the value of attribute standalone.



1215
1216
1217
# File 'lib/rss/rss.rb', line 1215

def standalone
  @standalone
end

#versionObject

Returns the value of attribute version.



1215
1216
1217
# File 'lib/rss/rss.rb', line 1215

def version
  @version
end

Instance Method Details

#feed_infoObject



1227
1228
1229
# File 'lib/rss/rss.rb', line 1227

def feed_info
  [@feed_type, @feed_version, @feed_subtype]
end

#initialize(feed_version, version = nil, encoding = nil, standalone = nil) ⇒ Object



1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
# File 'lib/rss/rss.rb', line 1216

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

#setup_maker(maker) ⇒ Object



1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
# File 'lib/rss/rss.rb', line 1236

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

#to_atom(type, &block) ⇒ Object



1259
1260
1261
# File 'lib/rss/rss.rb', line 1259

def to_atom(type, &block)
  to_feed("atom:#{type}", &block)
end

#to_feed(type, &block) ⇒ Object



1248
1249
1250
1251
1252
1253
# File 'lib/rss/rss.rb', line 1248

def to_feed(type, &block)
  Maker.make(type) do |maker|
    setup_maker(maker)
    block.call(maker) if block
  end
end

#to_rss(type, &block) ⇒ Object



1255
1256
1257
# File 'lib/rss/rss.rb', line 1255

def to_rss(type, &block)
  to_feed("rss#{type}", &block)
end

#to_xml(type = nil, &block) ⇒ Object



1263
1264
1265
1266
1267
1268
1269
# File 'lib/rss/rss.rb', line 1263

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