Class: FixerIo::Response::HistoricalRates

Inherits:
Object
  • Object
show all
Defined in:
lib/fixer_io/response/historical_rates.rb

Overview

Historical Rates response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ HistoricalRates

Create a new instance.

Parameters:

  • args (Hash)

    arguments used to create the object.

Options Hash (args):

  • :timestamp (Integer)

    the exact date and time the given rates were collected.

  • :base (String)

    the three-letter currency code of the base currency used for this request.

  • :rates (Hash)

    exchange rate data for the currencies.

  • :historical (Boolean)

    true if a request for historical exchange rates was made.

  • :date (String)

    the date for which historical rates were requested.



41
42
43
44
45
46
47
# File 'lib/fixer_io/response/historical_rates.rb', line 41

def initialize(args)
  @timestamp = Time.at args[:timestamp].to_i
  @base = args[:base].downcase.to_sym
  @rates = Response.symbolize_hash_keys args[:rates]
  @date = Date.parse args[:date]
  @historical = args[:historical]
end

Instance Attribute Details

#baseSymbol (readonly)

The three-letter currency code of the base currency used for this request.

Returns:

  • (Symbol)


15
16
17
# File 'lib/fixer_io/response/historical_rates.rb', line 15

def base
  @base
end

#dateDate (readonly)

The date for which historical rates were requested.

Returns:

  • (Date)


27
28
29
# File 'lib/fixer_io/response/historical_rates.rb', line 27

def date
  @date
end

#historicalBoolean (readonly)

Returns true if a request for historical exchange rates was made.

Returns:

  • (Boolean)


23
24
25
# File 'lib/fixer_io/response/historical_rates.rb', line 23

def historical
  @historical
end

#ratesHash<Symbol, Numeric> (readonly)

Exchange rate data for the currencies you have requested.

Returns:

  • (Hash<Symbol, Numeric>)


19
20
21
# File 'lib/fixer_io/response/historical_rates.rb', line 19

def rates
  @rates
end

#timestampTime (readonly)

The exact date and time the given rates were collected.

Returns:

  • (Time)


10
11
12
# File 'lib/fixer_io/response/historical_rates.rb', line 10

def timestamp
  @timestamp
end