Class: ECB::Exchange::XMLFeed

Inherits:
Object
  • Object
show all
Defined in:
lib/ecb/exchange/xml_feed.rb

Constant Summary collapse

NINETY_DAY_ENDPOINT =
"https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.endpointObject

Returns the value of attribute endpoint.



16
17
18
# File 'lib/ecb/exchange/xml_feed.rb', line 16

def endpoint
  @endpoint
end

Class Method Details

.rates(date) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/ecb/exchange/xml_feed.rb', line 23

def self.rates(date)
  if date > Date.today
    raise ArgumentError.new("invalid date, must be today or in the past")
  end

  # find rates in cache, or fetch (and cache)
  date  = date.to_s
  rates = Cache.read(date) || fetch_and_cache[date]
  rates ? rates : raise(DateNotFoundError.new(date))
end