require "money_swap/version" require 'nokogiri' require 'open-uri' class Money 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 end