class HG::Finance::CryptoCurrency

Attributes

buy[RW]

Public: Price to buy

exchange[RW]

Public: Exchange

iso_code[RW]

Public: ISO code

last[RW]

Public: Last ticker

name[RW]

Public: Name

sell[RW]

Public: Price to seel

to_currency[RW]

Public: To currency

variation[RW]

Public: Last day variation

Public Class Methods

new(options = {}) click to toggle source
# File lib/hg/finance/crypto_currency.rb, line 31
def initialize(options = {})
  if options.count != 0
    @exchange    = options[:exchange] if options[:exchange]
    @name        = options[:name] if options[:name]
    @iso_code    = options[:iso_code] if options[:iso_code]
    @to_currency = options[:to_currency] if options[:to_currency]
    @buy         = options[:buy].to_f if options[:buy]
    @sell        = options[:sell].to_f if options[:sell]
    @last        = options[:last].to_f if options[:last]
    @variation   = options[:variation].to_f if options[:variation]
  end
end

Public Instance Methods

inspect() click to toggle source
# File lib/hg/finance/crypto_currency.rb, line 57
def inspect
  self.to_s
end
to_s(separator = ' - ') click to toggle source
# File lib/hg/finance/crypto_currency.rb, line 44
def to_s separator = ' - '
  to_return = []

  to_return << self.exchange.to_s + ' (' + self.iso_code.to_s + ' to ' + self.to_currency + ')'

  to_return << "#{Locale.get_format(:last).to_s.capitalize}: " + "#{self.to_currency} #{self.last}" if self.last
  to_return << "#{Locale.get_format(:buy).to_s.capitalize}: " + "#{self.to_currency} #{self.buy}" if self.buy
  to_return << "#{Locale.get_format(:sell).to_s.capitalize}: " + "#{self.to_currency} #{self.sell}" if self.sell
  to_return << "#{Locale.get_format(:variation).to_s.capitalize}: " + self.variation.to_s if self.variation

  return to_return.join(separator)
end