summaryrefslogtreecommitdiff
path: root/lib
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 /lib
parent656a6c347c14b7e79dbed1bf59c30f6232d08ae5 (diff)
* 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
Diffstat (limited to 'lib')
-rw-r--r--lib/date/format.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/date/format.rb b/lib/date/format.rb
index ca890cf..8bd14c7 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