Sha256: dbc4f40bd874ed5006925b4474d8c78b2b253c2b1463032c877d03c73290845b

Contents?: true

Size: 401 Bytes

Versions: 3

Compression:

Stored size: 401 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
    end

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

      response
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nanook-1.0.2 lib/nanook/util.rb
nanook-1.0.1 lib/nanook/util.rb
nanook-1.0.0 lib/nanook/util.rb