这有时很难让你的头,但是你需要打开与特定类对象相关联的单例的“特征类”.其语法是class<<自己做...结束
class Time
alias :old_strftime :strftime
def strftime
puts "got here"
old_strftime
end
end
class Time
class << self
alias :old_Now :Now
def Now
puts "got here too"
old_Now
end
end
end
t = Time.Now
puts t.strftime