Created
May 25, 2014 03:03
-
-
Save sebabelmar/ccc61b625355a4771e21 to your computer and use it in GitHub Desktop.
gang_app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COHORT_LIST = [ | |
{name: "Adam Dziuk", cellphone_number: "+19992223344"}, | |
{name: "Adam Ryssdal", cellphone_number: "+19992223344"}, | |
{name: "Aki Suzuki", cellphone_number: "+19992223344"}, | |
{name: "Allison Wong", cellphone_number: "+19992223344"}, | |
{name: "Andra Lally", cellphone_number: "+19992223344"}, | |
{name: "Anup Pradhan", cellphone_number: "+19992223344"}, | |
{name: "CJ Jameson", cellphone_number: "+19992223344"}, | |
{name: "Christiane Kammerl", cellphone_number: "+19992223344"}, | |
{name: "Christopher Aubuchon", cellphone_number: "+19992223344"}, | |
{name: "Clark Hinchcliff", cellphone_number: "+19992223344"}, | |
{name: "Devin Johnson", cellphone_number: "+19992223344"}, | |
{name: "Dominick Oddo", cellphone_number: "+19992223344"}, | |
{name: "Kevin Kang", cellphone_number: "+19992223344"}, | |
{name: "Eiko Seino", cellphone_number: "+19992223344"}, | |
{name: "Eoin McMillan", cellphone_number: "+19992223344"}, | |
{name: "Hunter Chapman", cellphone_number: "+19992223344"}, | |
{name: "Jacob Persing", cellphone_number: "+19992223344"}, | |
{name: "Jon Pabico", cellphone_number: "+19992223344"}, | |
{name: "Joshua Rosaaen", cellphone_number: "+19992223344"}, | |
{name: "Nadia Koroleva", cellphone_number: "+19992223344"}, | |
{name: "Parjam Davoody", cellphone_number: "+19992223344"}, | |
{name: "Renee Schaaf", cellphone_number: "+19992223344"}, | |
{name: "Samuel Davis", cellphone_number: "+19992223344"}, | |
{name: "Sebastian Belmar", cellphone_number: "+19992223344"}, | |
{name: "Shawn Seibert", cellphone_number: "+19992223344"}, | |
{name: "Butler Bushyhead", cellphone_number: "+19992223344"}, | |
{name: "Yuzu Saijo", cellphone_number: "+19992223344"} | |
] | |
class Boot | |
attr_reader :name | |
def initialize(args = {}) | |
@name = args[:name] | |
@cellphone_number = args[:cellphone_number] | |
end | |
end | |
class Pair | |
attr_reader :a, :b | |
def initialize(a, b = Solo.new) | |
@a = a | |
@b = b | |
end | |
class Solo | |
attr_reader :name | |
def initialize | |
@name = "Solo Fly or find copilot!" | |
end | |
end | |
end | |
class Cohort | |
def initialize(name) | |
@name = name | |
@all_boots = COHORT_LIST.map {|boot|Boot.new(boot)} #database | |
@gangs_of_the_week = {} | |
@possible_pairs = {} | |
end | |
def gang_creator(*boots_per_gang) | |
cohort_names = @all_boots | |
raise("Check your boots per gang!") if cohort_names.length != boots_per_gang.inject(:+) | |
number_of_gangs = boots_per_gang.length | |
# Shuffle the cohort and boots_per_gang | |
cohort_shuffled = cohort_names.shuffle | |
boots_per_gang_shuffled = boots_per_gang.shuffle | |
# Creates a Hash of group_number as keys and boots as values | |
number_of_gangs.times do |counter| | |
@gangs_of_the_week["gang_#{counter+1}"] = cohort_shuffled.pop(boots_per_gang_shuffled.pop) | |
end | |
return @gangs_of_the_week | |
end | |
def possible_pairs_per_gang | |
@gangs_of_the_week.each do |gang_name, boots| | |
pairs = [] | |
boots.shuffle.each_slice(2) do |pair| | |
pairs << Pair.new(*pair) | |
end | |
@possible_pairs[gang_name] = pairs | |
end | |
@possible_pairs | |
end | |
def print | |
@possible_pairs.each do |gang, pairs| | |
puts "#{gang}" | |
pairs.each do |pair| | |
puts "#{pair.a.name} - #{pair.b.name}" | |
end | |
end | |
end | |
end | |
# fence_lizards = Cohort.new("Fence Lizards") | |
# fence_lizards.gang_creator(7,7,7,6) | |
# fence_lizards.possible_pairs_per_gang | |
# fence_lizards.print | |
# puts "*"*60 | |
# fence_lizards.possible_pairs_per_gang | |
# fence_lizards.print | |
# puts "*"*60 | |
# fence_lizards.possible_pairs_per_gang | |
# fence_lizards.print | |
# puts "*"*60 | |
# fence_lizards.possible_pairs_per_gang | |
# fence_lizards.print | |
# puts "*"*60 | |
# __END__ | |
class Gangs_of_the_week | |
def initialize | |
@fence_lizards = Cohort.new("Fence Lizards") | |
@fence_lizards.gang_creator(7,7,7,6) | |
@days = ["mon", "tue", "wed", "thu", "fri"] | |
@weekly_gangs = {} | |
# @a = @fence_lizards.possible_pairs_per_gang | |
# @b = @fence_lizards.possible_pairs_per_gang | |
# @c = @fence_lizards.possible_pairs_per_gang | |
# @d = @fence_lizards.possible_pairs_per_gang | |
# @e = @fence_lizards.possible_pairs_per_gang | |
# @pp = [@a, @b, @c, @d, @e] | |
end | |
def daily_pairs | |
@days.each_with_index {|day, idx| @weekly_gangs[day] = @fence_lizards.possible_pairs_per_gang} | |
@weekly_gangs | |
end | |
def print_possible_pairs(day) | |
@weekly_gangs[day].each do |k, v| | |
puts "#{k}" | |
v.each { |pair| puts "#{pair.a.name} - #{pair.b.name} "} | |
puts "" | |
end | |
end | |
def print_possible_daily_pairs(day, gang) | |
puts "This is your Gang for this week!!" | |
puts "Here you have a possible pair distribution:" | |
puts "" | |
@weekly_gangs[day][gang].each do |pair| | |
puts "#{pair.a.name} - #{pair.b.name}" | |
end | |
end | |
end | |
a = Gangs_of_the_week.new | |
# a.print_possible_pairs | |
# a.pee | |
a.daily_pairs | |
# puts "This are the possible pairs for all GANGS! on Mon" | |
# puts "" | |
# a.print_possible_pairs("mon") | |
# puts "*"*60 | |
puts "" | |
a.print_possible_daily_pairs("mon","gang_1") | |
a.daily_pairs | |
puts "*"*60 | |
a.print_possible_daily_pairs("tue","gang_1") | |
puts "*"*60 | |
a.daily_pairs | |
# a.print_possible_daily_pairs("wed","gang_1") | |
# puts "*"*60 | |
# a.print_possible_daily_pairs("thu","gang_1") | |
# puts "*"*60 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment