class RailsCurrency::Convertor::Xe

Constants

CURRENCIES

Public Class Methods

convert(amount, from, to) click to toggle source
# File lib/rails_currency/conversion_services/xe.rb, line 95
def convert(amount, from, to)
  Convertor.convert(amount, from, to, 'xe')
end
get_rate(from, to) click to toggle source
# File lib/rails_currency/conversion_services/xe.rb, line 106
def get_rate(from, to)
  convert(1, from, to)
end
process_request(amount, from, to) click to toggle source
# File lib/rails_currency/conversion_services/xe.rb, line 99
def process_request(amount, from, to)
  url = "#{service_url}?Amount=#{amount}&From=#{from}&To=#{to}"
  doc = open(url, Convertor::PARAMS) { |f| Hpricot(f) }
  result = doc.search("//table[@class='ucc-result-table']//tr[@class='uccResUnit']/td[@class='leftCol']")
  result[0].inner_text.split('=')[1].gsub(/\s/, '').to_f
end
service_url() click to toggle source
# File lib/rails_currency/conversion_services/xe.rb, line 91
def service_url
  'http://www.xe.com/currencyconverter/convert'
end