Class: MyTradeWizard::Email

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#subjectObject

Returns the value of attribute subject.



6
7
8
# File 'lib/mytradewizard/email.rb', line 6

def subject
  @subject
end

Instance Method Details

#<<(msg) ⇒ Object



9
10
11
# File 'lib/mytradewizard/email.rb', line 9

def <<(msg)
  @body << msg << "\n"
end

#sendObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mytradewizard/email.rb', line 13

def send
  to = MyTradeWizard::Configuration::Email::TO
  subject = @subject
  body = @body
  username = MyTradeWizard::Configuration::Email::GMAIL_USERNAME
  password = MyTradeWizard::Configuration::Email::GMAIL_PASSWORD
  unless to.empty? || username.empty? || password.empty?
    Gmail.connect!(username, password) do |gmail|
      gmail.deliver! do
        to(to)
        subject(subject)
        body(body)
      end
    end
  end
end