Class: RakeMailer::FileWriter

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

Instance Method Summary collapse

Constructor Details

#initialize(emails = nil) ⇒ FileWriter

Returns a new instance of FileWriter.



9
10
11
12
13
14
15
# File 'lib/rake_mailer.rb', line 9

def initialize(emails = nil)
  load_yml
  set_email_config(emails)
  set_file_config
  create_file_path
  open_file         
end

Instance Method Details

#closeObject



26
27
28
29
30
31
32
33
# File 'lib/rake_mailer.rb', line 26

def close
  begin
    @file.close
  rescue Exception => e
    puts "ERROR: Block in close. Rescued. Will attempt to send the mail. Could close the file => #{e.message}"
  end
  send_email
end

#file_writer(line) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rake_mailer.rb', line 17

def file_writer(line)
  begin
    @file.write(line)
    @file.write("\n")
  rescue Exception => e
    puts "ERROR: Block in file_writer. Rescued. Could not write in the file => #{e.message}"
  end  
end