Class: RubePost

Inherits:
Object
  • Object
show all
Defined in:
lib/rube_post.rb

Defined Under Namespace

Classes: Email, Grabber

Constant Summary collapse

VERSION =
File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ RubePost

Returns a new instance of RubePost.



7
8
9
# File 'lib/rube_post.rb', line 7

def initialize(username, password)
  @grabber = Grabber.new(username, password)
end

Instance Method Details

#emails_in_inboxObject



11
12
13
# File 'lib/rube_post.rb', line 11

def emails_in_inbox
  @grabber.emails_in_inbox.map{|d| Email.new(d, @grabber) }
end

#move_to_gmail(username, password) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rube_post.rb', line 15

def move_to_gmail(username, password)
  require 'gmail'
  my_email = (username.include?('@') ? username : "#{username}@gmail.com")
  Gmail.connect(username, password) do |gmail|
    emails_in_inbox.each do |email|
      gmail.deliver do
        to my_email
        subject email.subject
        text_part do
          body "#{email.sender}:\nepost-id:#{email.id}\n\n#{email.content}"
        end
      end
      email.move_to_trash
    end
  end
end