Module: Spark

Defined in:
lib/spark.rb

Constant Summary collapse

Bars =
'▁▂▃▄▅▆▇█'

Class Method Summary collapse

Class Method Details

.draw(*values) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/spark.rb', line 8

def draw(*values)
  min = values.min
  f = [((values.max - min) << 8) / (Bars.length - 1), 1].max
  ret = ''
  values.each do |val|
   ret << Bars[((val - min) << 8) / f]
  end
  ret
end