Module: ComputeUnit::Formatters

Included in:
ComputeBase
Defined in:
lib/compute_unit/formatters.rb

Instance Method Summary collapse

Instance Method Details

#micro_formatter(item, add_unit = false) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/compute_unit/formatters.rb', line 5

def micro_formatter(item, add_unit = false)
  data = {}
  item.each do |key, value|
    if %i[hourly_cost hourly_earnings kwh_cost].include?(key)
      v = (value * 1000000).round(4)
      data[key] = add_unit ? "#{v} \u00B5BTC" : v
    end
  end
  item.merge(data)
end

#value_micro_formatter(value, add_unit = false) ⇒ Object



16
17
18
19
# File 'lib/compute_unit/formatters.rb', line 16

def value_micro_formatter(value, add_unit = false)
  v = (value * 1000000).round(1)
  add_unit ? "#{v} \u00B5BTC" : v
end