Skip to content

Instantly share code, notes, and snippets.

@chaffeqa
Created September 8, 2012 20:04
Show Gist options
  • Save chaffeqa/3679277 to your computer and use it in GitHub Desktop.
Save chaffeqa/3679277 to your computer and use it in GitHub Desktop.
Griff's eyes only
class OtherTask < Task
def complete?
...
end
end
class Scoreboard
attr :teams
end
class Task
attr :team
def initialize(team)
self.team = team
end
def complete
team.task_completed
end
def complete?
true
end
end
class Team
attr :on_complete_procs
attr :tasks
def initialize
tasks = []
tasks << OtherTask.new(self)
tasks << WebpageGetTask.new(self)
on_complete_procs = []
end
def on_task_completed(&proc)
on_completed_procs << proc
end
def task_completed
on_complete_procs.each {|func|
func.call
end
end
def unfinished_tasks
tasks.select {|task|
!task.complete?
}
end
def finished_all_tasks?
tasks.any? {|task|
!task.complete?
}
end
end
class WebpageGetTask < Task
def complete?
...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment