class BigDecimal
Public Instance Methods
inspect()
click to toggle source
# File lib/dohutil/core_ext/inspect.rb, line 27 def inspect "#<BigDecimal:#{to_s('F')}>" end
to_d()
click to toggle source
# File lib/dohutil/core_ext/bigdecimal.rb, line 14 def to_d self end
to_dig(digits_after_decimal = 2)
click to toggle source
# File lib/dohutil/core_ext/bigdecimal.rb, line 24 def to_dig(digits_after_decimal = 2) raise ArgumentError.new("digits_after_decimal must be >= 0") if digits_after_decimal < 0 if nan? || infinite? return '0' if digits_after_decimal == 0 return '0.' + ('0' * digits_after_decimal) end if digits_after_decimal == 0 return to_i.to_s end retval = truncate(digits_after_decimal).to_s('F') digits_needed = retval.index('.') + digits_after_decimal + 1 - retval.size retval += ('0' * digits_needed) if digits_needed > 0 retval end
to_display()
click to toggle source
# File lib/dohutil/to_display.rb, line 40 def to_display '$' + to_dig(2) end
to_s(format = 'F')
click to toggle source
# File lib/dohutil/core_ext/bigdecimal.rb, line 20 def to_s(format = 'F') _doh_original_to_s(format) end
Also aliased as: _doh_original_to_s