Sha256: abea99308d94b30becd3f707e21cb8f7542c9be77ac4c40f8bd467d53ae17dc9

Contents?: true

Size: 498 Bytes

Versions: 3

Compression:

Stored size: 498 Bytes

Contents

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
money_swap-0.1.2 lib/money_swap.rb
money_swap-0.1.1 lib/money_swap.rb
money_swap-0.1.0 lib/money_swap.rb