diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-24 08:09:04 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-24 08:09:04 +0000 |
commit | aac0f41dbfc5a42f6158eb5f5539a530967967d4 (patch) | |
tree | 322de9b61d67c4fb7c2d3d08f718c996938f52a8 | |
parent | 656a6c347c14b7e79dbed1bf59c30f6232d08ae5 (diff) | |
download | ruby-aac0f41dbfc5a42f6158eb5f5539a530967967d4.tar.gz |
* lib/date/format.rb: updated based on date2 4.0.3.
(Use one instance variable instead of many)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@11857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/date/format.rb | 16 |
2 files changed, 12 insertions, 8 deletions
@@ -1,3 +1,7 @@ +Sat Feb 24 17:04:01 2007 Tadayoshi Funaba <tadf@dotrb.org> + + * lib/date/format.rb: updated based on date2 4.0.3. + Sat Feb 24 17:01:02 2007 Minero Aoki <aamine@loveruby.net> * ext/racc/cparse/cparse.c (cparse_params_mark): remove useless diff --git a/lib/date/format.rb b/lib/date/format.rb index ca890cf8f5..8bd14c7fd0 100644 --- a/lib/date/format.rb +++ b/lib/date/format.rb @@ -96,23 +96,23 @@ class Date class Bag # :nodoc: + def initialize + @elem = {} + end + def method_missing(t, *args, &block) t = t.to_s set = t.chomp!('=') - t = '@' + t + t = t.intern if set - instance_variable_set(t, *args) + @elem[t] = args[0] else - if instance_variables.include?(t) - instance_variable_get(t) - end + @elem[t] end end def to_hash - instance_variables. - select{|n| !instance_variable_get(n).nil?}.grep(/\A@[^_]/). - inject({}){|r, n| r[n[1..-1].intern] = instance_variable_get(n); r} + @elem.reject{|k, v| /\A_/ =~ k.to_s || v.nil?} end end |