Created
September 10, 2013 17:07
-
-
Save asonas/6512441 to your computer and use it in GitHub Desktop.
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
class Arranger | |
def initialize(capacity, file_path) | |
@capacity = capacity | |
@members = parse_members_text(file_path) | |
@members.shuffle! | |
end | |
def decision | |
@members.first(@capacity) | |
end | |
def next_decision | |
@members.last(@members.length - @capacity) | |
end | |
private | |
def parse_members_text(file_path) | |
text = File.read(file_path, encoding: Encoding::UTF_8) | |
text.rstrip.split(/\r?\n/).map { |line| line.chomp } | |
end | |
end | |
snorkel_driver = Arranger.new(6, "snorkel_members.txt") | |
puts "---First car members---" | |
puts snorkel_driver.decision | |
puts "---Second car members---" | |
puts snorkel_driver.next_decision | |
glassboat_driver = Arranger.new(6, "glassboat_members.txt") | |
puts "---First car members---" | |
puts glassboat_driver.decision | |
puts "---Second car members---" | |
puts glassboat_driver.next_decision |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment