Method: Gmail#initialize
- Defined in:
- lib/gmail.rb
#initialize(username, password) ⇒ Gmail
Returns a new instance of Gmail.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gmail.rb', line 10 def initialize(username, password) # This is to hide the username and password, not like it REALLY needs hiding, but ... you know. # Could be helpful when demoing the gem in irb, these bits won't show up that way. = class << self class << self attr_accessor :username, :password end self end .username = username =~ /@/ ? username : username + '@gmail.com' .password = password @imap = Net::IMAP.new('imap.gmail.com',993,true,nil,false) @imap.login(username, password) if block_given? yield self logout end end |