Class: MsgExtractor::Recipient
- Inherits:
-
Object
- Object
- MsgExtractor::Recipient
- Defined in:
- lib/msg_extractor/recipient.rb
Constant Summary collapse
- TO =
1- CC =
2- BCC =
3
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, email:, type:) ⇒ Recipient
constructor
A new instance of Recipient.
- #to_s ⇒ Object
Constructor Details
#initialize(name:, email:, type:) ⇒ Recipient
Returns a new instance of Recipient.
9 10 11 12 13 |
# File 'lib/msg_extractor/recipient.rb', line 9 def initialize(name:, email:, type:) @name = name @email = email @type = type end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
7 8 9 |
# File 'lib/msg_extractor/recipient.rb', line 7 def email @email end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/msg_extractor/recipient.rb', line 7 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/msg_extractor/recipient.rb', line 7 def type @type end |
Class Method Details
.from_storage(cfbf, storage) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/msg_extractor/recipient.rb', line 15 def self.from_storage(cfbf, storage) props = Mapi::PropertyStore.new(cfbf, storage, :recipient) email = props[Mapi::PR_SMTP_ADDRESS] if email.nil? address = props[Mapi::PR_EMAIL_ADDRESS] email = address if address&.include?("@") end new(name: props[Mapi::PR_DISPLAY_NAME], email: email, type: props[Mapi::PR_RECIPIENT_TYPE] || TO) end |
Instance Method Details
#to_s ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/msg_extractor/recipient.rb', line 26 def to_s if name && email && name != email "#{name} <#{email}>" else (email || name).to_s end end |