Class: Mapi::Msg
- Defined in:
- lib/mapi/msg.rb,
lib/mapi/convert/note-mime.rb,
lib/mapi/convert/note-tmail.rb
Overview
Introduction
Primary class interface to the vagaries of .msg files.
The core of the work is done by the PropertyStore class.
Defined Under Namespace
Classes: Attachment, Recipient
Constant Summary
Constants inherited from Message
Instance Attribute Summary collapse
Attributes inherited from Item
Class Method Summary collapse
-
.open(arg, mode = nil, helper = nil) ⇒ Ole::Storage::Dirent
Alternate constructor, to create an Msg directly from
arg
andmode
, passed directly to Ole::Storage (ie either filename or seekable IO object).
Instance Method Summary collapse
- #attachments ⇒ Array<Attachment>
- #close ⇒ Object
-
#initialize(root, helper) ⇒ Msg
constructor
Create an Msg from
root
, an Ole::Storage::Dirent object. - #recipients ⇒ Array<Recipient>
Methods inherited from Message
#body_to_mime, #body_to_tmail, #convert, #headers, #inspect, #mime, #mime_type, #to_mime, #to_post, #to_tmail, #to_vcard, #type
Constructor Details
#initialize(root, helper) ⇒ Msg
Create an Msg from root
, an Ole::Storage::Dirent object
400 401 402 403 404 405 406 |
# File 'lib/mapi/msg.rb', line 400 def initialize root, helper @root = root @helper = helper @close_parent = false super PropertySet.new(PropertyStore.load(@root, helper)) Msg.warn_unknown @root end |
Instance Attribute Details
#close_parent ⇒ Boolean
375 376 377 |
# File 'lib/mapi/msg.rb', line 375 def close_parent @close_parent end |
Class Method Details
.open(arg, mode = nil, helper = nil) ⇒ Ole::Storage::Dirent
Alternate constructor, to create an Mapi::Msg directly from arg
and mode
, passed
directly to Ole::Storage (ie either filename or seekable IO object).
384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/mapi/msg.rb', line 384 def self.open arg, mode=nil, helper=nil msg = new Ole::Storage.open(arg, mode).root, helper || Helper.new # we will close the ole when we are #closed msg.close_parent = true if block_given? begin yield msg ensure; msg.close end else msg end end |
Instance Method Details
#attachments ⇒ Array<Attachment>
422 423 424 425 426 427 |
# File 'lib/mapi/msg.rb', line 422 def @attachments ||= @root.children. select { |child| child.dir? and child.name =~ ATTACH_RX }. map { |child| Attachment.new child, helper }. select { |attach| attach.valid? } end |
#close ⇒ Object
417 418 419 |
# File 'lib/mapi/msg.rb', line 417 def close @root.ole.close if @close_parent end |