module RiksbankCurrency::Helper
Public Instance Methods
currency_from_seriesid(seriesid)
click to toggle source
Extract currency ISO name from Riksbank series name Example: SEKEURPMI => EUR
@see www.riksbank.se/en/Interest-and-exchange-rates/Series-for-web-services/
@param [String] Riksbank SeriesId
# File lib/riksbank_currency/helper.rb, line 11 def currency_from_seriesid(seriesid) unless (matches = seriesid.match(/SEK(\w+)PMI/)).nil? matches[1] end end
currency_to_seriesid(currency)
click to toggle source
Generate series name for specific currency @param [String] currency ISO name
# File lib/riksbank_currency/helper.rb, line 19 def currency_to_seriesid(currency) "SEK#{currency.upcase}PMI" end
format_date(date)
click to toggle source
Converts date to the bank format @param [Date] date
# File lib/riksbank_currency/helper.rb, line 25 def format_date(date) date.strftime("%Y-%m-%d") end
parse_date(string_date)
click to toggle source
Parse date from bank format @param [String] date string in format “YYYY-MM-DD” @return [Date]
# File lib/riksbank_currency/helper.rb, line 32 def parse_date(string_date) Date.new(*string_date.split('-').map(&:to_i)) end