Class: SpotRate::GoogleCurrencyConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/spot_rate/google_currency_converter.rb

Constant Summary collapse

GOOGLE_CURRENCY_URI =
'http://www.google.com/ig/calculator?hl=en&q=1%s=?%s'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_currency, to_currency) ⇒ GoogleCurrencyConverter

Returns a new instance of GoogleCurrencyConverter.



9
10
11
12
# File 'lib/spot_rate/google_currency_converter.rb', line 9

def initialize from_currency, to_currency
  @from_currency = from_currency
  @to_currency   = to_currency
end

Instance Attribute Details

#from_currencyObject

Returns the value of attribute from_currency.



7
8
9
# File 'lib/spot_rate/google_currency_converter.rb', line 7

def from_currency
  @from_currency
end

#to_currencyObject

Returns the value of attribute to_currency.



7
8
9
# File 'lib/spot_rate/google_currency_converter.rb', line 7

def to_currency
  @to_currency
end

Instance Method Details

#spot_rateObject



14
15
16
17
# File 'lib/spot_rate/google_currency_converter.rb', line 14

def spot_rate
  @response = Net::HTTP.get ccy_api_uri
  validate_converter_response! and pluck_spot_rate_from_converter_response
end