Sha256: 613c714577f25914152fd2b0b330fcc4c41fcc139073c5b8e44f401e87f687b9
Contents?: true
Size: 432 Bytes
Versions: 3
Compression:
Stored size: 432 Bytes
Contents
module SecretSantaPicker class Pair attr_accessor :from, :to def self.generate(persons:) all_people = persons.dup.shuffle all_people.map.with_index do |person, index| to_person = index == (all_people.count - 1) ? all_people[0] : all_people[index + 1] Pair.new(from: person, to: to_person) end end def initialize(from:, to:) @from = from @to = to end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
secret_santa_picker-0.2.1 | lib/secret_santa_picker/pair.rb |
secret_santa_picker-0.2.0 | lib/secret_santa_picker/pair.rb |
secret_santa_picker-0.1.0 | lib/secret_santa_picker/pair.rb |