Hi,

In <9e7db9110606140929i710f5c61n2d7f93ab6bae503 / mail.gmail.com>
  "Re: [ANN] rubyrss-1.0" on Thu, 15 Jun 2006 01:29:29 +0900,
  "Austin Ziegler" <halostatue / gmail.com> wrote:

> I'm thinking more something like:
> 
>   rss = RSS.new do |r|
>     r.channel.XXX = XXX
> 	...
> 	r.items.new_item do |i|
> 	  i.content_encoded = YYY
> 	end
> 	...
>   end

It seems good that items.new_item do ... end style. I'll
add codes that support your style to RSS Maker.

>   %w(0.91 1.0 2.0).each do |version|
>     File.open("#{version}.xml", "w") do |f|
> 	  f.print(rss.to_xml(version))
> 	end
>   end
> 
> The difference is that you create three "external" objects to satisfy
> 0.91, 1.0, and 2.0. I would create one "external" object and create
> other objects on-the-fly. This might be:
> 
>   class RSS
>     def to_xml(version = nil)
> 	  version ||= @default_version
> 	  rss.to_version(version).to_xml
> 	end
>   end

I see. I probably understand your idea. What about the
following idea:

  require 'rss'

  module RSS
    module RootElementMixin
      def to_xml(version=nil)
        if version.nil? or version == @rss_version
          to_s
        else
          RSS::Maker.make(version) do |maker|
            setup_maker(maker)
          end.to_s
        end
      end
    end
  end

  rss = RSS::Maker.make(...) do
    ...
  end

  %w(0.91 1.0 2.0).each do |version|
    File.open("#{version}.xml", "w") do |f|
      f.print(rss.to_xml(version))
    end
  end


> Similarly, it would be nice to have something like:
> 
>   rss = RSS.from_file("0.91.xml")
>   File.open("2.0.xml") { |f| f.print rss.to_xml("2.0") }

Now, we can write like the following:

  rss = RSS::Parser.parse("0.91.xml")
  File.open("2.0.xml") {|f| f.print rss.to_xml("2.0")}


If the above RSS::RootElementMixin#to_xml satisfies you,
I'll commit those changes to Ruby's CVS.


Thanks,
--
kou