class Numeric
@@currencies = {'yen' => 0.013, 'euro' => 1.292, 'rupee' => 0.019, 'dollar' => 1.0}
def method_missing(method, *args)
singular_currency = (method == :in ? args.first : method).to_s.gsub(/s$/, '')
if @@currencies.has_key?(singular_currency)
self.send(method == :in ? :/ : :*, @@currencies[singular_currency])
else
super
end
end
end
我没有得到确切的代码,我知道,它是用于转换的,但我没有得到三元运算符部分。