Sha256: 544626cf409fdf8109e58993b69be705d0e6a10b2b246ec1dd21675b0ca4e901
Contents?: true
Size: 600 Bytes
Versions: 6
Compression:
Stored size: 600 Bytes
Contents
# frozen_string_literal: true class Numeric # Converts this numeric to a Money object in the default currency. It # multiplies the numeric value by 100 and treats that as cents. # # NOTE!!! # This is overriden as per the default Money .to_money because it assumes # a different default currency... # # 100.to_money => #<Money @cents=10000> # 100.37.to_money => #<Money @cents=10037> # require 'bigdecimal' # BigDecimal.new('100').to_money => #<Money @cents=10000> def to_money(currency = nil) ::Money.new((self * 100).round, currency || Money.default_currency) end end
Version data entries
6 entries across 6 versions & 1 rubygems