Class: EmlFile
- Inherits:
-
Object
- Object
- EmlFile
- Includes:
- BasicLogging, File_Checking, Translating
- Defined in:
- lib/emlfile.rb
Overview
A representation of an EML-file. Wraps the Mail-object (from the Mail-gem).
Constant Summary collapse
- @@MAIL_INTRO =
"From "
- @@errors =
[]
Constants included from BasicLogging
BasicLogging::DEBUG, BasicLogging::ERROR, BasicLogging::FATAL, BasicLogging::INFO, BasicLogging::Levels, BasicLogging::UNKNOWN, BasicLogging::WARN
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
Attributes included from BasicLogging
Instance Method Summary collapse
-
#initialize(filename) ⇒ EmlFile
constructor
create the representation of 1 eml-file.
-
#mails(&b) ⇒ Object
call the given block on each individual mail-file.
-
#method_missing(method, *args) ⇒ Object
delegate messages, that this object cannot respond to to the Mail-object.
Methods included from Translating
Methods included from File_Checking
Methods included from BasicLogging
is_muted?, #log, mute, #set_level, #set_target
Constructor Details
#initialize(filename) ⇒ EmlFile
create the representation of 1 eml-file
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/emlfile.rb', line 37 def initialize(filename) debug 'EMLFile - is ' << inspect debug('log initialized') @attachments = nil @body = nil @headers = nil msg = file_check(filename, :exist, :file, :readable) debug('file checked: ' << msg.to_s) @@errors << msg if msg # split the file into many, one for each e-mail if(!msg) split(filename) else error(trl("Invalid file") << ": %s (%s)" %[filename,msg] ) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
delegate messages, that this object cannot respond to to the Mail-object
55 56 57 58 59 60 61 |
# File 'lib/emlfile.rb', line 55 def method_missing(method, *args) if(@mail.respond_to?(method) ) @mail.send(method, *args) else error(trl("method %s is undefined for objects of class %s") %[method, self.class.name]) end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
32 33 34 |
# File 'lib/emlfile.rb', line 32 def body @body end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
32 33 34 |
# File 'lib/emlfile.rb', line 32 def filename @filename end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
32 33 34 |
# File 'lib/emlfile.rb', line 32 def files @files end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
32 33 34 |
# File 'lib/emlfile.rb', line 32 def headers @headers end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
32 33 34 |
# File 'lib/emlfile.rb', line 32 def msg @msg end |
Instance Method Details
#mails(&b) ⇒ Object
call the given block on each individual mail-file
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/emlfile.rb', line 63 def mails(&b) if(@files) debug('working on the files: ' << @files.join(', ')) @files.each do |f| parse(f) @filename=f yield(self) end end end |