filters: refactor #sample to leave off the arg

This commit is contained in:
Parker Moore 2015-12-04 13:48:09 -08:00
parent 2e91d094e5
commit 47d2a2459d
1 changed files with 4 additions and 4 deletions

View File

@ -283,11 +283,11 @@ module Jekyll
def sample(input, num = 1)
return input unless input.respond_to?(:sample)
sampling = input.sample(num)
if num == 1
sampling.first
n = num.to_i rescue 1
if n == 1
input.sample
else
sampling
input.sample(n)
end
end