Module: ExchangeRatesNBP

Defined in:
lib/exchange_rates_nbp.rb,
lib/exchange_rates_nbp/version.rb,
lib/exchange_rates_nbp/clients/table_list.rb,
lib/exchange_rates_nbp/clients/currency_data_set.rb

Defined Under Namespace

Modules: Clients

Constant Summary collapse

BASE_URL =
'http://www.nbp.pl/kursy/xml/'.freeze
FILE_NAME_YEAR_PATTERN =
'dir{year}.txt'.freeze
FILE_NAME_CURRENT_YEAR =
'dir.txt'.freeze
TABLE_TYPES =

‘xnnnzrrmmdd.xml’

{
  middle_exchange_rates_table_a: 'a',
  middle_exchange_rates_table_b: 'b',
  buy_and_sell_table: 'c',
  settlement_units_table: 'h'
}.freeze
DEFAULT_TABLE_TYPES =
TABLE_TYPES.values.first
VERSION =
'0.1.3'.freeze

Class Method Summary collapse

Class Method Details

.exchange_rate(date, currency_code, table = DEFAULT_TABLE_TYPES) ⇒ Object



24
25
26
# File 'lib/exchange_rates_nbp.rb', line 24

def self.exchange_rate(date, currency_code, table = DEFAULT_TABLE_TYPES)
  exchange_rate_info(date, currency_code, table)[:exchange_rate]
end

.exchange_rate_info(date, currency_code, table = DEFAULT_TABLE_TYPES) ⇒ Object



28
29
30
31
# File 'lib/exchange_rates_nbp.rb', line 28

def self.exchange_rate_info(date, currency_code, table = DEFAULT_TABLE_TYPES)
  table_id = find_table_id(date, table)
  exchange_rate_hash(table_id, currency_code)
end