python - Ruby on Rails : Dependencies and Nodes -
i have simple problem needs solving. have code sorts out tasks dependant on other tasks. examaple tasks a, b, c, , d. these need sorting in order of dependancies. example, task b can completed after task d done. therefore order of tasks : a d b c i have code in python, there way make code work in rails (as in correct syntax/method) class node: def __init__(self, name): self.name = name self.edges = [] def addedge(self, node): self.edges.append(node) require 'set' class circulardependencieserror < exception end class task attr_reader :name, :depends def initialize(task_name, dependencies=[]) @name = task_name @depends = set.new dependencies end def add_dependencies(*d) @depends.merge d end def <=>(rhs) if depends.include?(rhs.name) , rhs.depends.include?(name) raise circulardependencieserror, "#{name} , #{rhs.name} depend on each other" elsif rhs.depends.include? name ...