Simplify (and optimize)

This commit is contained in:
Marc-Andre Lafortune 2012-11-16 03:35:42 -05:00
parent 22edb664cf
commit 3c4a0b2e68

@ -67,9 +67,9 @@ def in_groups(number, fill_with = nil)
number.times do |index|
length = division + (modulo > 0 && modulo > index ? 1 : 0)
padding = fill_with != false &&
modulo > 0 && length == division ? 1 : 0
groups << slice(start, length).concat([fill_with] * padding)
groups << last_group = slice(start, length)
last_group << fill_with if fill_with != false &&
modulo > 0 && length == division
start += length
end