Class: Suc::Reports::Email

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

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ Email

Returns a new instance of Email.



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

def initialize(report)
  @report = report
end

Instance Method Details

#cc_recipientsObject



19
20
21
# File 'lib/reports/email.rb', line 19

def cc_recipients
  Suc.email_cc_recipients
end

#exportObject



23
24
25
26
27
28
# File 'lib/reports/email.rb', line 23

def export
  headers = { 'subject' => escape(subject), 'body' => escape(@report.body)}
  headers.merge!({ 'cc' => cc_recipients }) if cc_recipients
  escaped_email = URI::MailTo.build({to: recipients, headers: headers}).to_s
  system(Suc.email_client, escaped_email)
end

#recipientsObject



15
16
17
# File 'lib/reports/email.rb', line 15

def recipients
  Suc.email_recipients || '[email protected]'
end

#subjectObject



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

def subject
  "Work Report week##{@report.week} #{@report.year}"
end