Sha256: c3728811ac15c0349113f35e6b94759be56a838b06d4d2908fb98c5b75346f7d

Contents?: true

Size: 528 Bytes

Versions: 2

Compression:

Stored size: 528 Bytes

Contents

# Helper methods to
# - convert empty or integer values into BigDecimals
module SK::Calc::Helper

  private

  # Init price single with 0 if nil and cast to BigDecimal
  # == Return
  # <BigDecimal>
  def conv_price_single
    to_bd(price_single || 0)
  end

  # Init tax with 0 if nil and cast to BigDecimal
  # == Return
  # <BigDecimal>
  def conv_tax
    to_bd(tax || 0)
  end

  # Cast a val to BigDecimal
  # == Return
  # <BigDecimal>
  def to_bd(val)
    val.is_a?(BigDecimal) ? val : BigDecimal.new("#{val}")
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sk_calc-0.0.5 lib/sk_calc/helper.rb
sk_calc-0.0.4 lib/sk_calc/helper.rb