Return to Snippet

Revision: 5934
at April 14, 2008 05:06 by plexus


Initial Code
#!/usr/bin/env ruby -w

unless ARGV.length == 3
  puts "\tUsage :\n\t\t#{File.basename($0)} 100 eur usd"
  exit
end

require 'ubygems'
require 'open-uri'
require 'hpricot'

url = "http://xurrency.com/#{ARGV.join('/')}/feed"
doc=Hpricot(open(url).read)

puts (doc/'dc:value').inner_html

Initial URL
http://www.arnebrasseur.net

Initial Description
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.

Initial Title
Command line Currency converter

Initial Tags
ruby, convert

Initial Language
Ruby