Module: MinerMover::Ore

Defined in:
lib/miner_mover.rb

Overview

ore is handled in blocks of 1M

Constant Summary collapse

BLOCK =
1_000_000

Class Method Summary collapse

Class Method Details

.block(ore, size = BLOCK) ⇒ Object

raw ore in, blocks out



24
25
26
# File 'lib/miner_mover.rb', line 24

def self.block(ore, size = BLOCK)
  ore.to_f / size
end

.display(ore) ⇒ Object

entirely used for display purposes



42
43
44
# File 'lib/miner_mover.rb', line 42

def self.display(ore)
  format("%s ore", self.units(ore))
end

.units(ore) ⇒ Object

mostly used for display purposes



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/miner_mover.rb', line 29

def self.units(ore)
  if ore % BLOCK == 0 or ore > BLOCK * 100
    format("%iM", self.block(ore).round)
  elsif ore > BLOCK
    format("%.2fM", self.block(ore))
  elsif ore > 10_000
    format("%iK", self.block(ore, 1_000).round)
  else
    format("%i", ore)
  end
end