Class: GmailToDo
- Inherits:
-
Object
- Object
- GmailToDo
- Defined in:
- lib/gmail_todo.rb
Constant Summary collapse
- LOCAL_CREDENTIALS =
ENV['HOME'] + '/.gmail_todo/credentials.yml'
- DEFAULT_CREDENTIALS =
File.dirname(__FILE__) + '/credentials.yml'
Instance Method Summary collapse
-
#initialize ⇒ GmailToDo
constructor
A new instance of GmailToDo.
- #password ⇒ Object
- #send_todo(todo, details = nil) ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize ⇒ GmailToDo
Returns a new instance of GmailToDo.
8 9 10 11 12 13 |
# File 'lib/gmail_todo.rb', line 8 def initialize file = File.exists?(LOCAL_CREDENTIALS) ? LOCAL_CREDENTIALS : DEFAULT_CREDENTIALS credentials = YAML.load(File.read(file)) @username = credentials["gmail"]["username"] @password = credentials["gmail"]["password"] end |
Instance Method Details
#password ⇒ Object
19 20 21 |
# File 'lib/gmail_todo.rb', line 19 def password @password end |
#send_todo(todo, details = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gmail_todo.rb', line 23 def send_todo(todo, details = nil) gmail = Gmail.connect(username, password) gmail.deliver do to gmail.username subject "[ToDo] #{todo}" body "#{details}" end gmail.logout end |
#username ⇒ Object
15 16 17 |
# File 'lib/gmail_todo.rb', line 15 def username @username end |