summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-24 08:09:04 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-24 08:09:04 +0000
commitaac0f41dbfc5a42f6158eb5f5539a530967967d4 (patch)
tree322de9b61d67c4fb7c2d3d08f718c996938f52a8
parent656a6c347c14b7e79dbed1bf59c30f6232d08ae5 (diff)
downloadruby-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--ChangeLog4
-rw-r--r--lib/date/format.rb16
2 files changed, 12 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 808411c45c..4d3870d21c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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