Class: GmailToDo

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

Constant Summary collapse

CREDENTIALS =
ENV['HOME'] + '/.gmail_todo_credentials.yml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGmailToDo

Returns a new instance of GmailToDo.



10
11
12
13
14
15
16
# File 'lib/gmail_todo.rb', line 10

def initialize
  if File.exists?(CREDENTIALS)
    load_credentials
  else
    prompt_for_credentials
  end
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



8
9
10
# File 'lib/gmail_todo.rb', line 8

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

#send(todo, details = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gmail_todo.rb', line 18

def send(todo, details = nil)
  gmail = Gmail.connect(username, password)

  gmail.deliver do
    to gmail.username
    subject "[ToDo] #{todo}"
    body "#{details}"
  end

  gmail.logout
end