2018-10-10 14:39:25 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-11-19 20:06:47 +01:00
|
|
|
require "currency"
|
|
|
|
require "money/currency"
|
2018-10-10 14:39:25 +02:00
|
|
|
|
|
|
|
class CurrencyNames
|
|
|
|
def cache_key
|
|
|
|
Digest::MD5.hexdigest(currencies.first.date.to_s)
|
|
|
|
end
|
|
|
|
|
|
|
|
def formatted
|
|
|
|
iso_codes.each_with_object({}) do |iso_code, result|
|
|
|
|
result[iso_code] = Money::Currency.find(iso_code).name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def iso_codes
|
2024-11-19 20:06:47 +01:00
|
|
|
currencies.map(&:iso_code).append("EUR").sort
|
2018-10-10 14:39:25 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def currencies
|
|
|
|
@currencies ||= find_currencies
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_currencies
|
|
|
|
Currency.latest.all
|
|
|
|
end
|
|
|
|
end
|