5 def create_integer(min, max, minus)
6 min, max = [min, max].map {|i| i < 0 ? -i : i }.sort
21 def factor(options, target = 'factor')
22 create_integer(options[:"#{target}_min"], options[:"#{target}_max"], options[:"#{target}_minus"])
25 def single(a, b, v = 'x')
28 x, y = v.values_at(0, 1)
29 ("(%d%s + %d%s)" % [a, x, b, y]).
31 gsub(/1(?!\d)(#{v.join('|')})/, '\1')
34 def min_max_order(options, targets)
35 targets.each do |type|
36 min = options[:"#{type}_min"]
37 if min > options[:"#{type}_max"]
38 options[:"#{type}_max"] = min
47 unless public_method_defined?(:sample)
50 shuffle.slice(0..(n-1))