2024-08-01 21:14:28 +02:00
|
|
|
module Tables
|
|
|
|
class Table < Array
|
2024-08-02 17:37:50 +02:00
|
|
|
attr_writer :discomfort
|
2024-08-02 18:17:22 +02:00
|
|
|
attr_reader :id
|
2024-08-02 17:37:50 +02:00
|
|
|
|
2024-08-01 21:14:28 +02:00
|
|
|
def initialize(*args)
|
|
|
|
super
|
2024-08-02 18:17:22 +02:00
|
|
|
@id = SecureRandom.uuid
|
2024-08-01 21:14:28 +02:00
|
|
|
end
|
|
|
|
|
2024-08-02 17:37:50 +02:00
|
|
|
def discomfort
|
|
|
|
@discomfort ||= DiscomfortCalculator.new(self).calculate
|
|
|
|
end
|
2024-08-02 18:42:24 +02:00
|
|
|
|
2024-08-02 18:49:18 +02:00
|
|
|
def swap_candidates
|
|
|
|
@swap_candidates ||= uniq { |person| person.affinity_group_list.first }
|
|
|
|
end
|
|
|
|
|
2024-08-02 18:42:24 +02:00
|
|
|
def dup
|
|
|
|
super.tap do |new_table|
|
|
|
|
new_table.discomfort = nil
|
|
|
|
end
|
|
|
|
end
|
2024-08-01 21:14:28 +02:00
|
|
|
end
|
2024-08-02 17:37:50 +02:00
|
|
|
end
|