class Mailbox

container for mail methods

Public Class Methods

new(info) click to toggle source
# File lib/mailchekka/mailbox.rb, line 3
def initialize(info)
  @info = info
  @box  = nil
end

Public Instance Methods

getnum() click to toggle source
# File lib/mailchekka/mailbox.rb, line 23
def getnum
  if @info.pop
    num_pop
  else
    num_imap
  end
end
prepare() click to toggle source
# File lib/mailchekka/mailbox.rb, line 8
def prepare
  host = @info.host
  port = @info.port
  ssl  = @info.ssl
  user = [@info.login, @info.password]
  if @info.pop
    @box = Net::POP3.new(host, port)
    @box.use_ssl if ssl
    @box.start(*user)
  else
    @box = Net::IMAP.new(host, port, ssl: ssl)
    @box.login(*user)
  end
end

Private Instance Methods

imap_end() click to toggle source
# File lib/mailchekka/mailbox.rb, line 44
def imap_end
  @box.logout
  @box.disconnect
end
num_imap() click to toggle source
# File lib/mailchekka/mailbox.rb, line 37
def num_imap
  @box.examine('INBOX')
  number = @box.search('UNSEEN').length
  imap_end
  number
end
num_pop() click to toggle source
# File lib/mailchekka/mailbox.rb, line 33
def num_pop
  @box.mails.length
end