Sha256: 1ff8c8bde7bda2353815025cd02e3cf3309f94f38b8cf6c48347ec54b54e0835

Contents?: true

Size: 425 Bytes

Versions: 2

Compression:

Stored size: 425 Bytes

Contents

require 'bigdecimal'

class Nanook
  class Util

    STEP = BigDecimal.new("10")**BigDecimal.new("30")

    def self.NANO_to_raw(nano)
      (BigDecimal.new(nano.to_s) * STEP).to_i
    end

    def self.raw_to_NANO(raw)
      (raw.to_f / STEP).to_f
    end

    def self.coerce_empty_string_to_type(response, type)
      if response == "" || response.nil?
        return type.new
      end

      response
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nanook-2.1.0 lib/nanook/util.rb
nanook-2.0.0 lib/nanook/util.rb