Sha256: 87ce58f49bbc1b410fd7c4bd4509901c9d2b53eb2358025c74830fa7efdf1734

Contents?: true

Size: 555 Bytes

Versions: 3

Compression:

Stored size: 555 Bytes

Contents

module Pyk::NumberHelpers
  
  def two_decimal_points(ff)
    sprintf("%0.02f", ff)
  end
  
  def remove_decimal(str)
    str = str.to_s
    if str.index(".").present?
      str = str[0..(str.index(".") - 1)]
    end
    str
  end
  
  def n2h(d)
    begin
      return number_to_human(d, significant: false, precision: 1)
    rescue
      return d
    end
  end
  
  def color_amount(d)
    if d < 0
      "<span class='red'>(#{number_to_currency(d, unit: '')})</span>".html_safe
    else
      number_to_currency(d, unit: '')
    end
  end
        
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pyk-0.0.3 lib/pyk/number_helpers.rb
pyk-0.0.2 lib/pyk/number_helpers.rb
pyk-0.0.1 lib/pyk/number_helpers.rb