Module: VectorNumber::NumericRefinements::BigDecimalToD
- Defined in:
- lib/vector_number/numeric_refinements.rb
Overview
Note:
‘BigDecimal` needs to be defined for this refinement to activate.
Refinement module to change Kernel#BigDecimal so it works with #to_d
.
Instance Method Summary collapse
-
#BigDecimal(value, ndigits = nil, exception: true) ⇒ BigDecimal?
BigDecimal() that first tries to use #to_d.
Instance Method Details
#BigDecimal(value, exception: true) ⇒ BigDecimal? #BigDecimal(value, ndigits, exception: true) ⇒ BigDecimal?
BigDecimal() that first tries to use #to_d.
73 74 75 76 77 78 79 |
# File 'lib/vector_number/numeric_refinements.rb', line 73 def BigDecimal(value, ndigits = nil, exception: true) # rubocop:disable Naming/MethodName if value.respond_to?(:to_d) ndigits.nil? ? value.to_d : value.to_d(ndigits) else ndigits.nil? ? super(value, exception: exception) : super end end |