Created
September 8, 2012 20:04
-
-
Save chaffeqa/3679277 to your computer and use it in GitHub Desktop.
Griff's eyes only
This file contains hidden or 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 OtherTask < Task | |
def complete? | |
... | |
end | |
end |
This file contains hidden or 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 Scoreboard | |
attr :teams | |
end |
This file contains hidden or 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 Task | |
attr :team | |
def initialize(team) | |
self.team = team | |
end | |
def complete | |
team.task_completed | |
end | |
def complete? | |
true | |
end | |
end |
This file contains hidden or 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 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 |
This file contains hidden or 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 WebpageGetTask < Task | |
def complete? | |
... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment