From c04f4aa0ee1a70768c785ac00160eb0e0f22d7fc Mon Sep 17 00:00:00 2001 From: tadf Date: Sun, 18 Feb 2007 10:34:58 +0000 Subject: updated based on date2 4.0.3. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/date/format.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/date/format.rb') diff --git a/lib/date/format.rb b/lib/date/format.rb index 7a4633a638..7c7c9f988b 100644 --- a/lib/date/format.rb +++ b/lib/date/format.rb @@ -1,5 +1,5 @@ # format.rb: Written by Tadayoshi Funaba 1999-2007 -# $Id: format.rb,v 2.30 2007-01-07 09:16:24+09 tadf Exp $ +# $Id: format.rb,v 2.31 2007-02-18 12:08:09+09 tadf Exp $ require 'rational' @@ -95,23 +95,24 @@ class Date end class Bag # :nodoc: + def initialize - @_dict = {} + @elem = {} end def method_missing(t, *args, &block) - if /=$/ =~ t - t = t.to_s.chomp('=').to_sym - @_dict[t] = args[0] + t = t.to_s + set = t.chomp!('=') + t = t.intern + if set + @elem[t] = args[0] else - if @_dict.key?(t) - @_dict[t] - end + @elem[t] end end def to_hash - @_dict.reject{|k,v| /^_/ =~ k} + @elem.reject{|k, v| /\A_/ =~ k.to_s || v.nil?} end end -- cgit v1.2.3