Class: MailDaemon::Imap::Watcher
- Inherits:
-
Object
- Object
- MailDaemon::Imap::Watcher
- Defined in:
- lib/mail_daemon/imap/watcher.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Watcher
constructor
A new instance of Watcher.
- #mailbox ⇒ Object
- #restart ⇒ Object
- #running? ⇒ Boolean
- #start(&block) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options) ⇒ Watcher
Returns a new instance of Watcher.
6 7 8 9 |
# File 'lib/mail_daemon/imap/watcher.rb', line 6 def initialize() @options = end |
Instance Method Details
#mailbox ⇒ Object
37 38 39 |
# File 'lib/mail_daemon/imap/watcher.rb', line 37 def mailbox @options[:mailbox] end |
#restart ⇒ Object
28 29 30 31 |
# File 'lib/mail_daemon/imap/watcher.rb', line 28 def restart stop start end |
#running? ⇒ Boolean
33 34 35 |
# File 'lib/mail_daemon/imap/watcher.rb', line 33 def running? @connection.running? end |
#start(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mail_daemon/imap/watcher.rb', line 11 def start(&block) @connection = Imap::Connection.new(@options, &block) @connection.login # @thread = Thread.new do @connection. do || yield :type => "incoming_email", :mailbox => @options, :inbound_message => end # end # @thread.join end |
#stop ⇒ Object
23 24 25 26 |
# File 'lib/mail_daemon/imap/watcher.rb', line 23 def stop @connection.disconnect # @thread.terminate end |