Class: Nomics::Currencies

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/nomics/currencies.rb

Instance Method Summary collapse

Constructor Details

#initialize(*currencies) ⇒ Currencies

Returns a new instance of Currencies.



5
6
7
# File 'lib/nomics/currencies.rb', line 5

def initialize(*currencies)
  @currencies = currencies.map { |symbol| Currency.new(symbol) }
end

Instance Method Details

#eachObject



9
10
11
# File 'lib/nomics/currencies.rb', line 9

def each
  @currencies.map { |currency| yield currency }
end

#lastObject



13
14
15
# File 'lib/nomics/currencies.rb', line 13

def last
  @currencies.last
end

#pluck(*attributes) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/nomics/currencies.rb', line 17

def pluck(*attributes)
  if attributes.one?
    map { |currency| currency.send(attributes.first) }
  else
    map do |currency|
      [].tap do |data|
        attributes.each { |attribute| data << currency.send(attribute) }
      end
    end
  end
end

#reloadObject



29
30
31
# File 'lib/nomics/currencies.rb', line 29

def reload
  @currencies.each &:reload
end