Created
October 15, 2015 16:20
-
-
Save jdmorlan/244af04d4600eed2489a 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
def get_prerequisites(requirement_type, course, requirement_collection) | |
course.send(requirement_type).each do |pre| | |
requirement_collection << pre.prerequisites | |
get_prerequisites(requirement_type, pre, requirement_collection) | |
end | |
end | |
def requirement_graph(requirement_type) | |
course_map = [self.send(requirement_type)] | |
get_prerequisites(requirement_type, self, course_map) | |
return course_map.flatten | |
end | |
def prerequisites_graph | |
requirement_graph(:prerequisites) | |
end | |
def corequisites_graph | |
requirement_graph(:corequisites) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment