mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-25 04:22:28 +01:00
e5815737c1
- bumped gems - rm bots - rm pry byebug - added rubocop-shopify and corrected generated warnings
31 lines
522 B
Ruby
31 lines
522 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "currency"
|
|
require "money/currency"
|
|
|
|
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
|
|
currencies.map(&:iso_code).append("EUR").sort
|
|
end
|
|
|
|
def currencies
|
|
@currencies ||= find_currencies
|
|
end
|
|
|
|
def find_currencies
|
|
Currency.latest.all
|
|
end
|
|
end
|