title: Ruby - method_missing
body: <p>I'm trying to implement a method_missing for converting $ to other currencies, as in doing 5.dollars yields 5, 5.yen would yield 0.065 5.euro 6.56 and so on. This I can do now. Now I need to implement it but doing 5.dollars.in(:yen) for example.</p>
  
  <p>This is what I have right now: </p>
  
  <pre><code>class Numeric
    @@currencies = {'yen' =&gt; 0.013, 'euro' =&gt; 1.292, 'rupee' =&gt; 0.019}
    def method_missing(method_id)
      singular_currency = method_id.to_s.gsub( /s$/, '')
      if @@currencies.has_key?(singular_currency)
        self * @@currencies[singular_currency]
      else
        super
      end
    end
  end
  </code></pre>
  
  <p>Can anyone explain how I can do this?</p>
  
  <p>PS: I'd rather you not give me the code, but an explanation, so I can determine on my own  how it is done.</p>