Class: BigDecimal
- Defined in:
- lib/doh/mysql/to_sql.rb,
lib/doh/core/bigdecimal.rb,
lib/doh/util/to_display.rb
Instance Method Summary collapse
- #_doh_original_to_s ⇒ Object
- #inspect ⇒ Object
- #to_d ⇒ Object
- #to_dig(digits_after_decimal = 2) ⇒ Object
- #to_display ⇒ Object
- #to_s(format = 'F') ⇒ Object
- #to_sql ⇒ Object
Instance Method Details
#_doh_original_to_s ⇒ Object
11 |
# File 'lib/doh/core/bigdecimal.rb', line 11 alias :_doh_original_to_s :to_s |
#inspect ⇒ Object
21 22 23 |
# File 'lib/doh/core/bigdecimal.rb', line 21 def inspect to_s end |
#to_d ⇒ Object
16 17 18 |
# File 'lib/doh/core/bigdecimal.rb', line 16 def to_d self end |
#to_dig(digits_after_decimal = 2) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/doh/core/bigdecimal.rb', line 25 def to_dig(digits_after_decimal = 2) raise ArgumentError.new("digits_after_decimal must be > 0") unless digits_after_decimal > 0 return '0.' + ('0' * digits_after_decimal) if nan? || infinite? retval = truncate(digits_after_decimal).to_s digits_needed = retval.index('.') + digits_after_decimal + 1 - retval.size retval += ('0' * digits_needed) if digits_needed > 0 retval end |
#to_display ⇒ Object
35 36 37 |
# File 'lib/doh/util/to_display.rb', line 35 def to_display '$' + to_dig(2) end |
#to_s(format = 'F') ⇒ Object
12 13 14 |
# File 'lib/doh/core/bigdecimal.rb', line 12 def to_s(format = 'F') _doh_original_to_s(format) end |
#to_sql ⇒ Object
42 43 44 |
# File 'lib/doh/mysql/to_sql.rb', line 42 def to_sql to_s('F') end |