Class: MailRoom::Connection
- Inherits:
-
Object
- Object
- MailRoom::Connection
- Defined in:
- lib/mail_room/connection.rb
Instance Method Summary collapse
-
#disconnected? ⇒ Boolean
is the imap connection closed?.
-
#idling? ⇒ Boolean
is the connection blocked idling?.
-
#initialize(mailbox) ⇒ Connection
constructor
A new instance of Connection.
-
#logged_in? ⇒ Boolean
is the connection logged in?.
- #on_new_message(&block) ⇒ Object
- #quit ⇒ Object
-
#ready_to_idle? ⇒ Boolean
is the connection ready to idle?.
- #wait ⇒ Object
Constructor Details
#initialize(mailbox) ⇒ Connection
Returns a new instance of Connection.
3 4 5 6 7 8 9 |
# File 'lib/mail_room/connection.rb', line 3 def initialize(mailbox) @mailbox = mailbox # log in and set the mailbox reset setup end |
Instance Method Details
#disconnected? ⇒ Boolean
is the imap connection closed?
29 30 31 |
# File 'lib/mail_room/connection.rb', line 29 def disconnected? @imap.disconnected? end |
#idling? ⇒ Boolean
is the connection blocked idling?
23 24 25 |
# File 'lib/mail_room/connection.rb', line 23 def idling? @idling end |
#logged_in? ⇒ Boolean
is the connection logged in?
17 18 19 |
# File 'lib/mail_room/connection.rb', line 17 def logged_in? @logged_in end |
#on_new_message(&block) ⇒ Object
11 12 13 |
# File 'lib/mail_room/connection.rb', line 11 def (&block) @new_message_handler = block end |
#quit ⇒ Object
39 40 41 42 |
# File 'lib/mail_room/connection.rb', line 39 def quit stop_idling reset end |
#ready_to_idle? ⇒ Boolean
is the connection ready to idle?
35 36 37 |
# File 'lib/mail_room/connection.rb', line 35 def ready_to_idle? logged_in? && !idling? end |
#wait ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mail_room/connection.rb', line 44 def wait begin # in case we missed any between idles process_mailbox idle process_mailbox rescue Net::IMAP::Error, IOError @mailbox.logger.warn({ context: @mailbox.context, action: "Disconnected. Resetting..." }) reset setup end end |