summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-30 13:12:22 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-30 13:12:22 +0000
commit0c416eb2bb298cb0bf0b04b9446ec21c8c168972 (patch)
treeaa16c716e98d034014eb767aada146e606e3d475 /lib
parent48925716c49735e751dffaede68a4d9dcef68cc5 (diff)
* lib/date.rb: refined deprecated methods.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/date.rb58
1 files changed, 38 insertions, 20 deletions
diff --git a/lib/date.rb b/lib/date.rb
index bd3f25a013..90a4a01ca3 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -1694,6 +1694,42 @@ end
class Date
+ class << self
+
+ def deprecated_class_method_alias(old, new) # :nodoc:
+ module_eval <<-"end;"
+ class << self
+ def #{old}(*args, &block)
+ if $VERBOSE
+ warn("\#{caller.shift.sub(/:in .*/, '')}: " \
+ "warning: \#{self}::#{old} is deprecated; " \
+ "use \#{self}::#{new}")
+ end
+ #{new}(*args, &block)
+ end
+ end
+ end;
+ end
+
+ private :deprecated_class_method_alias
+
+ def deprecated_alias(old, new) # :nodoc:
+ module_eval <<-"end;"
+ def #{old}(*args, &block)
+ if $VERBOSE
+ warn("\#{caller.shift.sub(/:in .*/, '')}: " \
+ "warning: \#{self.class}\##{old} is deprecated; " \
+ "use \#{self.class}\##{new}")
+ end
+ #{new}(*args, &block)
+ end
+ end;
+ end
+
+ private :deprecated_alias
+
+ end
+
[ %w(os? julian?),
%w(ns? gregorian?),
%w(exist1? valid_jd?),
@@ -1707,16 +1743,7 @@ class Date
%w(new3 new),
%w(neww commercial)
].each do |old, new|
- module_eval <<-"end;"
- def self.#{old}(*args, &block)
- if $VERBOSE
- warn("\#{caller.shift.sub(/:in .*/, '')}: " \
- "warning: \#{self}::#{old} is deprecated; " \
- "use \#{self}::#{new}")
- end
- #{new}(*args, &block)
- end
- end;
+ deprecated_class_method_alias(old, new)
end
[ %w(os? julian?),
@@ -1726,16 +1753,7 @@ class Date
%w(of offset),
%w(newof new_offset)
].each do |old, new|
- module_eval <<-"end;"
- def #{old}(*args, &block)
- if $VERBOSE
- warn("\#{caller.shift.sub(/:in .*/, '')}: " \
- "warning: \#{self.class}\##{old} is deprecated; " \
- "use \#{self.class}\##{new}")
- end
- #{new}(*args, &block)
- end
- end;
+ deprecated_alias(old, new)
end
private :of, :newof