Class: ExchangeRatesGenerator::Formatters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/exchange-rates-generator/formatters/base.rb

Direct Known Subclasses

Javascript, Ruby

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(currency, rates) ⇒ Base

Returns a new instance of Base.



14
15
16
17
# File 'lib/exchange-rates-generator/formatters/base.rb', line 14

def initialize(currency, rates)
  @currency = currency.to_s.upcase.to_sym
  @rates = rates
end

Instance Attribute Details

#currencyObject (readonly)

Returns the value of attribute currency.



12
13
14
# File 'lib/exchange-rates-generator/formatters/base.rb', line 12

def currency
  @currency
end

#ratesObject (readonly)

Returns the value of attribute rates.



12
13
14
# File 'lib/exchange-rates-generator/formatters/base.rb', line 12

def rates
  @rates
end

Class Method Details

.formattersArray

Returns all Formatters

Returns:

  • (Array)

    Array containing all Formatters



29
30
31
# File 'lib/exchange-rates-generator/formatters/base.rb', line 29

def formatters
  @formatters ||= []
end

.inherited(formatter) ⇒ Object

Records all new Formatters



34
35
36
# File 'lib/exchange-rates-generator/formatters/base.rb', line 34

def inherited(formatter)          
  self.formatters << formatter
end

Instance Method Details

#to_sObject



19
20
21
# File 'lib/exchange-rates-generator/formatters/base.rb', line 19

def to_s
  header + body + footer
end