From 456ba712fe921f2387611055b67090d70dfad071 Mon Sep 17 00:00:00 2001 From: kou Date: Fri, 25 Nov 2005 03:43:48 +0000 Subject: * lib/rss/rss.rb: improved type conversion. * lib/rss/1.0.rb: ditto. * lib/rss/0.9.rb: ditto. * lib/rss/2.0.rb: ditto. * lib/rss/image.rb: ditto. * lib/rss/syndication.rb: ditto. * test/rss/test_2.0.rb: added type conversion tests. * test/rss/test_accessor.rb: ditto. * test/rss/test_to_s.rb: ditto. * test/rss/test_syndication.rb: ditto. * test/rss/test_setup_maker_2.0.rb: ditto. * test/rss/test_setup_maker_1.0.rb: ditto. * test/rss/test_setup_maker_0.9.rb: ditto. * test/rss/test_maker_sy.rb: ditto. * test/rss/test_maker_image.rb: ditto. * test/rss/test_maker_2.0.rb: ditto. * test/rss/test_maker_0.9.rb: ditto. * test/rss/test_image.rb: ditto. * test/rss/test_maker_1.0.rb: use assert instead of assert_equal. * test/rss/rss-assertions.rb: improved type conversion assertions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rss/0.9.rb | 78 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 40 deletions(-) (limited to 'lib/rss/0.9.rb') diff --git a/lib/rss/0.9.rb b/lib/rss/0.9.rb index a4b2ba9b8f..f0060cbad5 100644 --- a/lib/rss/0.9.rb +++ b/lib/rss/0.9.rb @@ -269,7 +269,7 @@ module RSS def initialize(content=nil) super() - @content = content + self.content = content end end @@ -310,18 +310,12 @@ module RSS class Hour < Element include RSS09 - content_setup + content_setup(:integer) def initialize(content=nil) super() - @content = content - end - - remove_method :content= - def content=(value) - @content = value.to_i + self.content = content end - end end @@ -334,20 +328,24 @@ module RSS install_text_element(name) install_model(name, nil) end - %w(width height description).each do |name| - install_text_element(name) + [ + ["width", :integer], + ["height", :integer], + ["description"], + ].each do |name, type| + install_text_element(name, type) install_model(name, "?") end def initialize(url=nil, title=nil, link=nil, width=nil, height=nil, description=nil) super() - @url = url - @title = title - @link = link - @width = width - @height = height - @description = description + self.url = url + self.title = title + self.link = link + self.width = width + self.height = height + self.description = description end def to_s(need_convert=true, indent=calc_indent) @@ -386,21 +384,21 @@ module RSS [ ["domain", nil, true], - ["port", nil, true], + ["port", nil, true, :integer], ["path", nil, true], ["registerProcedure", nil, true], - ["protocol", nil ,true], - ].each do |name, uri, required| - install_get_attribute(name, uri, required) + ["protocol", nil, true], + ].each do |name, uri, required, type| + install_get_attribute(name, uri, required, type) end def initialize(domain=nil, port=nil, path=nil, rp=nil, protocol=nil) super() - @domain = domain - @port = port - @path = path - @registerProcedure = rp - @protocol = protocol + self.domain = domain + self.port = port + self.path = path + self.registerProcedure = rp + self.protocol = protocol end def to_s(need_convert=true, indent=calc_indent) @@ -511,8 +509,8 @@ module RSS def initialize(url=nil, content=nil) super() - @url = url - @content = content + self.url = url + self.content = content end private @@ -543,17 +541,17 @@ module RSS [ ["url", nil, true], - ["length", nil, true], + ["length", nil, true, :integer], ["type", nil, true], - ].each do |name, uri, required| - install_get_attribute(name, uri, required) + ].each do |name, uri, required, type| + install_get_attribute(name, uri, required, type) end def initialize(url=nil, length=nil, type=nil) super() - @url = url - @length = length - @type = type + self.url = url + self.length = length + self.type = type end def to_s(need_convert=true, indent=calc_indent) @@ -596,8 +594,8 @@ module RSS def initialize(domain=nil, content=nil) super() - @domain = domain - @content = content + self.domain = domain + self.content = content end private @@ -631,10 +629,10 @@ module RSS def initialize(title=nil, description=nil, name=nil, link=nil) super() - @title = title - @description = description - @name = name - @link = link + self.title = title + self.description = description + self.name = name + self.link = link end def to_s(need_convert=true, indent=calc_indent) -- cgit v1.2.3