Class: Baldrick::Servant
- Inherits:
-
Object
- Object
- Baldrick::Servant
- Defined in:
- lib/baldrick/servant.rb
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
- #add_task(task) ⇒ Object
- #follow(order) ⇒ Object
-
#initialize ⇒ Servant
constructor
A new instance of Servant.
- #serve ⇒ Object
Constructor Details
#initialize ⇒ Servant
Returns a new instance of Servant.
5 6 7 |
# File 'lib/baldrick/servant.rb', line 5 def initialize @tasks, @listeners = [], [] end |
Instance Method Details
#add_listener(listener) ⇒ Object
13 14 15 |
# File 'lib/baldrick/servant.rb', line 13 def add_listener listener @listeners << listener end |
#add_task(task) ⇒ Object
9 10 11 |
# File 'lib/baldrick/servant.rb', line 9 def add_task task @tasks << task end |
#follow(order) ⇒ Object
21 22 23 |
# File 'lib/baldrick/servant.rb', line 21 def follow order @tasks.each{|task| task.run order} end |
#serve ⇒ Object
17 18 19 |
# File 'lib/baldrick/servant.rb', line 17 def serve orders.each {|order| follow order} end |