Sha256: fe638586a8a75b7864c82cc50fe632d5085382ab814f87b3579e87896aa8e2ea
Contents?: true
Size: 754 Bytes
Versions: 1
Compression:
Stored size: 754 Bytes
Contents
require 'open-uri' require 'nokogiri' module Fixer class << self def daily get('daily') end def historical get('hist') end def historical_90 get('hist-90d') end private def get(type) path = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-#{type}.xml" feed = open(path).read doc = Nokogiri::XML(feed) doc.xpath('/gesmes:Envelope/xmlns:Cube/xmlns:Cube', doc.root.namespaces).map do |snapshot| { :date => snapshot['time'], :rates => snapshot.xpath('./xmlns:Cube').map do |fx| { :currency => fx['currency'], :rate => fx['rate'] } end } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fixer-0.3.0 | lib/fixer.rb |