module Convertify
Public Instance Methods
convert(amount, current, convert_to)
click to toggle source
# File lib/convertify.rb, line 6 def convert(amount, current, convert_to) url = URI('http://data.fixer.io/api/latest?access_key=77622eb94ba284531ea444fa6b591419&symbols=USD, CAD, AUD, PLN, MXN') response = Net::HTTP.get(url) response = JSON.parse(response) amount * response["rates"][convert_to] / response["rates"][current] end
format(num)
click to toggle source
# File lib/convertify.rb, line 13 def format(num) "$#{num.round(2)}" end