Method: Array#pick

Defined in:
lib/chance/core_extensions.rb

#pick(percent) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/chance/core_extensions.rb', line 47

def pick(percent)
  picks, percentage = [], percent.of(length).round
  while picks.length < percentage
    picks << random
    picks.uniq!
  end
  picks
end