Class: Nanook::Util
- Inherits:
-
Object
- Object
- Nanook::Util
- Defined in:
- lib/nanook/util.rb
Constant Summary collapse
- STEP =
BigDecimal.new("10")**BigDecimal.new("30")
Class Method Summary collapse
- .coerce_empty_string_to_type(response, type) ⇒ Object
- .NANO_to_raw(nano) ⇒ Object
- .raw_to_NANO(raw) ⇒ Object
Class Method Details
.coerce_empty_string_to_type(response, type) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/nanook/util.rb', line 16 def self.coerce_empty_string_to_type(response, type) if response == "" || response.nil? return type.new end response end |
.NANO_to_raw(nano) ⇒ Object
8 9 10 |
# File 'lib/nanook/util.rb', line 8 def self.NANO_to_raw(nano) (BigDecimal.new(nano.to_s) * STEP).to_i end |
.raw_to_NANO(raw) ⇒ Object
12 13 14 |
# File 'lib/nanook/util.rb', line 12 def self.raw_to_NANO(raw) (raw.to_f / STEP).to_f end |