diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-01 13:30:08 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-01 13:30:08 +0000 |
commit | c2d8185ba63818aee5457b178aa2e85a9e81b053 (patch) | |
tree | 14b80106549cee7003c56ccecac4027a24ad17d8 /lib/rss/maker | |
parent | 0aeea1ad38b6e033fd18ed1594c4fa4404710e53 (diff) | |
download | ruby-c2d8185ba63818aee5457b178aa2e85a9e81b053.tar.gz |
* lib/rss/maker/base.rb: changed xml-stylesheet's API of RSS Maker
to like item's one.
* lib/rss/xml-stylesheet.rb (RSS::XMLStyleSheet#guess_type): fixed
regular expression bug.
* test/rss/test_maker_xml-stylesheet.rb: updated tests for xml-stylesheet.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rss/maker')
-rw-r--r-- | lib/rss/maker/base.rb | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/lib/rss/maker/base.rb b/lib/rss/maker/base.rb index a9f1639503..eb61f37ee2 100644 --- a/lib/rss/maker/base.rb +++ b/lib/rss/maker/base.rb @@ -143,7 +143,7 @@ module RSS end def setup_xml_stylesheets(rss) - rss.xml_stylesheets = @xml_stylesheets.normalize + @xml_stylesheets.to_rss(rss) end end @@ -153,22 +153,41 @@ module RSS extend Forwardable - def_delegators(:@xml_stylesheets, :<<, :[], :[]=) + def_delegators(:@xml_stylesheets, :<<, :[], :[]=, :first, :last) + def_delegators(:@xml_stylesheets, :push, :pop, :shift, :unshift) def initialize(maker) super @xml_stylesheets = [] end - - def normalize - @xml_stylesheets.collect do |info| - make_xml_stylesheet(info) + + def to_rss(rss) + @xml_stylesheets.each do |xss| + xss.to_rss(rss) end end - private - def make_xml_stylesheet(info) - RSS::XMLStyleSheet.new(*info) + def new_xml_stylesheet + xss = XMLStyleSheet.new(@maker) + @xml_stylesheets << xss + xss + end + + class XMLStyleSheet + include Base + + ::RSS::XMLStyleSheet::ATTRIBUTES.each do |attribute| + attr_accessor attribute + add_need_initialize_variable(attribute) + end + + def to_rss(rss) + xss = ::RSS::XMLStyleSheet.new + set = setup_values(xss) + if set + rss.xml_stylesheets << xss + end + end end end |