Skip to Content Skip to Search
Methods
A
C
F
N

Class Public methods

currencies()

# File app/services/service/money.rb, line 20
def self.currencies
  %w[usd aed afn all amd ang aoa ars aud awg azn bam bbd bdt bgn bif bmd bnd bob brl bsd bwp bzd
    cad cdf chf clp cny cop crc cve czk djf dkk dop dzd egp etb eur fjd fkp gbp gel gip gmd gnf
    gtq gyd hkd hnl hrk htg huf idr ils inr isk jmd jpy kes kgs khr kmf krw kyd kzt lak lbp lkr
    lrd lsl mad mdl mga mkd mmk mnt mop mro mur mvr mwk mxn myr mzn nad ngn nio nok npr nzd pab
    pen pgk php pkr pln pyg qar ron rsd rub rwf sar sbd scr sek sgd shp sll sos srd std szl thb
    tjs top try ttd twd tzs uah ugx uyu uzs vnd vuv wst xaf xcd xof xpf yer zar zmw]
end

new(cents, currency)

# File app/services/service/money.rb, line 3
def initialize(cents, currency)
  @cents = cents
  @currency = currency&.downcase || "usd"
end

Instance Public methods

amount_value()

# File app/services/service/money.rb, line 8
def amount_value
  zero_decimal_currencies.include?(@currency) ? @cents : @cents / 100.0
end

format()

# File app/services/service/money.rb, line 12
def format
  if @cents
    explicit_currencies.include?(@currency) ? "#{amount} (#{@currency.upcase})" : amount
  else
    self.class.new(0, @currency).format
  end
end