public
Description: A simple DSL that generates HTML charts from an input DSL file
Homepage:
Clone URL: git://github.com/balinterdi/chart-maker-dsl.git
chart-maker-dsl / math_aux.rb
100644 17 lines (15 sloc) 0.399 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require "test/unit"
 
module MathAux
def self.normalize(numbers, to=1.0)
norm_rat = to / numbers.max
numbers.map { |n| n * norm_rat }
end
end
 
if __FILE__ == $0:
class MathAuxTester < Test::Unit::TestCase
def test_normalize
assert_equal([0.5, 1.0, 0.25, 0], MathAux::normalize([24, 48, 12, 0]))
assert_equal([40, 80, 20, 0], MathAux::normalize([24, 48, 12, 0], to=80.0))
end
end
end