Class: MailRoom::Coordinator
- Inherits:
-
Object
- Object
- MailRoom::Coordinator
- Defined in:
- lib/mail_room/coordinator.rb
Overview
Coordinate the mailbox watchers
Instance Attribute Summary collapse
-
#running ⇒ Object
(also: #running?)
Returns the value of attribute running.
-
#watchers ⇒ Object
Returns the value of attribute watchers.
Instance Method Summary collapse
-
#initialize(mailboxes) ⇒ Coordinator
constructor
build watchers for a set of mailboxes.
-
#quit ⇒ Object
quit each of the watchers when we’re done running.
-
#run ⇒ Object
start each of the watchers to running.
Constructor Details
#initialize(mailboxes) ⇒ Coordinator
build watchers for a set of mailboxes
9 10 11 12 13 |
# File 'lib/mail_room/coordinator.rb', line 9 def initialize(mailboxes) self.watchers = [] mailboxes.each {|box| self.watchers << MailboxWatcher.new(box)} end |
Instance Attribute Details
#running ⇒ Object Also known as: running?
Returns the value of attribute running.
5 6 7 |
# File 'lib/mail_room/coordinator.rb', line 5 def running @running end |
#watchers ⇒ Object
Returns the value of attribute watchers.
5 6 7 |
# File 'lib/mail_room/coordinator.rb', line 5 def watchers @watchers end |
Instance Method Details
#quit ⇒ Object
quit each of the watchers when we’re done running
29 30 31 |
# File 'lib/mail_room/coordinator.rb', line 29 def quit watchers.each(&:quit) end |
#run ⇒ Object
start each of the watchers to running
18 19 20 21 22 23 24 25 26 |
# File 'lib/mail_room/coordinator.rb', line 18 def run watchers.each(&:run) self.running = true sleep_while_running ensure quit end |