Module: UruguayanExchangeRates
- Defined in:
- lib/uruguayan_exchange_rates.rb,
lib/uruguayan_exchange_rates/util.rb,
lib/uruguayan_exchange_rates/error.rb,
lib/uruguayan_exchange_rates/version.rb,
lib/uruguayan_exchange_rates/constants.rb,
lib/uruguayan_exchange_rates/enumeration.rb
Defined Under Namespace
Classes: Constants, CurrencyNotFound, Enumeration, Error, InvalidCurrency, Util
Constant Summary collapse
- SERVICE_HOST =
'http://www.bancorepublica.com.uy'
- SERVICE_PATH =
'/c/portal/render_portlet?p_l_id=123137&p_p_id=ExchangeLarge_WAR_ExchangeRate5121_INSTANCE_P2Af'
- VERSION =
"1.0.1"
Class Method Summary collapse
Class Method Details
.exchange_rates(currency) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/uruguayan_exchange_rates.rb', line 10 def self.exchange_rates(currency) currency_raw = Constants[currency] raise InvalidCurrency, 'Invalid currency' if currency_raw.nil? util = Util.new(currency_raw: currency_raw) # Make request data = util.request_data # Find currency in page currency_data = util.find_currency(data) raise CurrencyNotFound, 'Currency not found' if currency_data.nil? # Get values util.extract_values(currency_data) end |