Class: Baldrick::Servant

Inherits:
Object
  • Object
show all
Defined in:
lib/baldrick/servant.rb

Instance Method Summary collapse

Constructor Details

#initializeServant

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

#serveObject



17
18
19
# File 'lib/baldrick/servant.rb', line 17

def serve
  orders.each {|order| follow order}
end