class Money

Public Class Methods

convert(currency_1,currency_2) click to toggle source
# File lib/money_swap.rb, line 7
def self.convert(currency_1,currency_2)
  xe = 0

  html_data = open("https://www.xe.com/currencyconverter/convert/?Amount=1&From=#{currency_1}&To=#{currency_2}").read
  nokogiri_object = Nokogiri::HTML(html_data)

  tagcloud_elements = nokogiri_object.xpath("//span[@class='uccResultAmount']")

  tagcloud_elements.each do |tagcloud_element|
    xe = tagcloud_element.text
  end

  xe
end