class Arbolito::Currency::Quote

Attributes

from[R]
to[R]

Public Class Methods

new(hash) click to toggle source
# File lib/arbolito/currency/quote.rb, line 6
def initialize(hash) 
  raise ArgumentError.new('You must specify 1 quote rate') if hash.size != 1

  @from = hash.keys.first.to_sym
  @to = hash.values.first.to_sym
end

Public Instance Methods

==(other_currency_quote) click to toggle source
# File lib/arbolito/currency/quote.rb, line 21
def ==(other_currency_quote)
  raise TypeError unless other_currency_quote.is_a?(Quote)

  @from == other_currency_quote.from && @to == other_currency_quote.to
end
backwards() click to toggle source
# File lib/arbolito/currency/quote.rb, line 17
def backwards 
  Quote.new( @to => @from )
end
to_hash() click to toggle source
# File lib/arbolito/currency/quote.rb, line 13
def to_hash
  { @from => @to }
end