Command line Currency converter


/ Published in: Ruby
Save to your folder(s)

Command line currency convertor, just copy and paste. I named mine 'coin'. Make sure you have Ruby, Rubygems and Hpricot (gem install hpricot).

e.g.
~$ coin 100 eur usd
158.3300

Uses the site xurrency.com.


Copy this code and paste it in your HTML
  1. #!/usr/bin/env ruby -w
  2.  
  3. unless ARGV.length == 3
  4. puts "\tUsage :\n\t\t#{File.basename($0)} 100 eur usd"
  5. exit
  6. end
  7.  
  8. require 'ubygems'
  9. require 'open-uri'
  10. require 'hpricot'
  11.  
  12. url = "http://xurrency.com/#{ARGV.join('/')}/feed"
  13. doc=Hpricot(open(url).read)
  14.  
  15. puts (doc/'dc:value').inner_html

URL: http://www.arnebrasseur.net

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.