Skip to content

Instantly share code, notes, and snippets.

@beathyate
Created November 27, 2013 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beathyate/7670794 to your computer and use it in GitHub Desktop.
Save beathyate/7670794 to your computer and use it in GitHub Desktop.
Convertidor simple
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
FROM = 'USD'
TO = 'PEN'
URL = "http://rate-exchange.appspot.com/currency?from=#{ FROM }&to=#{ TO }"
open URL do |rates_file|
hash = JSON.parse rates_file.string
puts hash['rate'].to_f * ARGV.first.to_f
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment