Class: Nomics::Currencies
- Inherits:
-
Object
- Object
- Nomics::Currencies
- Includes:
- Enumerable
- Defined in:
- lib/nomics/currencies.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(*currencies) ⇒ Currencies
constructor
A new instance of Currencies.
- #last ⇒ Object
- #pluck(*attributes) ⇒ Object
- #reload ⇒ Object
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
#each ⇒ Object
9 10 11 |
# File 'lib/nomics/currencies.rb', line 9 def each @currencies.map { |currency| yield currency } end |
#last ⇒ Object
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 |
#reload ⇒ Object
29 30 31 |
# File 'lib/nomics/currencies.rb', line 29 def reload @currencies.each &:reload end |