Module: Imglab::Sequence
Constant Summary collapse
- DEFAULT_SIZE =
16
Instance Method Summary collapse
-
#sequence(first, last, size = DEFAULT_SIZE) ⇒ Array<Integer>
Returns a geometric sequence of integer numbers inside an interval and with specific size as array.
Instance Method Details
#sequence(first, last, size = DEFAULT_SIZE) ⇒ Array<Integer>
Returns a geometric sequence of integer numbers inside an interval and with specific size as array.
23 24 25 26 27 28 29 30 31 |
# File 'lib/imglab/sequence.rb', line 23 def sequence(first, last, size = DEFAULT_SIZE) return [] if size <= 0 return [first] if size == 1 return [first, last] if size == 2 ratio = (last / first.to_f) ** (1 / (size - 1).to_f) progression(first, ratio).take(size - 1).map(&:round).push(last) end |