Class: EmailGraph::GmailFetcher::Message
- Inherits:
-
Struct
- Object
- Struct
- EmailGraph::GmailFetcher::Message
- Defined in:
- lib/email_graph/gmail_fetcher.rb
Instance Attribute Summary collapse
-
#bcc ⇒ Object
Returns the value of attribute bcc.
-
#cc ⇒ Object
Returns the value of attribute cc.
-
#date ⇒ Object
Returns the value of attribute date.
-
#from ⇒ Object
Returns the value of attribute from.
-
#to ⇒ Object
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(**kwargs) ⇒ Message
Returns a new instance of Message.
58 59 60 |
# File 'lib/email_graph/gmail_fetcher.rb', line 58 def initialize(**kwargs) kwargs.each{ |k, v| self[k] = v } end |
Instance Attribute Details
#bcc ⇒ Object
Returns the value of attribute bcc
56 57 58 |
# File 'lib/email_graph/gmail_fetcher.rb', line 56 def bcc @bcc end |
#cc ⇒ Object
Returns the value of attribute cc
56 57 58 |
# File 'lib/email_graph/gmail_fetcher.rb', line 56 def cc @cc end |
#date ⇒ Object
Returns the value of attribute date
56 57 58 |
# File 'lib/email_graph/gmail_fetcher.rb', line 56 def date @date end |
#from ⇒ Object
Returns the value of attribute from
56 57 58 |
# File 'lib/email_graph/gmail_fetcher.rb', line 56 def from @from end |
#to ⇒ Object
Returns the value of attribute to
56 57 58 |
# File 'lib/email_graph/gmail_fetcher.rb', line 56 def to @to end |
Class Method Details
.from_net_imap_envelope(e) ⇒ Message
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/email_graph/gmail_fetcher.rb', line 64 def self.from_net_imap_envelope(e) addresses_by_field = {} address_fields = [:from, :to, :cc, :bcc] address_fields.each do |field| addresses = e.attr['ENVELOPE'].send(field) || [] addresses_by_field[field] = addresses.map{ |a| Address.from_net_imap_address(a) } end date_raw = e.attr['ENVELOPE'].date date = nil begin date = Time.parse(date_raw) if date_raw rescue ArgumentError # Observed cases: # - date_raw == "{DATE}" # - Time.parse raises 'ArgumentError: argument out of range' end new(**addresses_by_field, date: date) end |