Class: InternetMessage::Received
- Inherits:
-
Object
- Object
- InternetMessage::Received
- Defined in:
- lib/internet_message/received.rb
Instance Attribute Summary collapse
-
#by ⇒ Object
readonly
Returns the value of attribute by.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#for ⇒ Object
readonly
Returns the value of attribute for.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#via ⇒ Object
readonly
Returns the value of attribute via.
-
#with ⇒ Object
readonly
Returns the value of attribute with.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(from, by, via, with, id, for_, date) ⇒ Received
constructor
A new instance of Received.
Constructor Details
#initialize(from, by, via, with, id, for_, date) ⇒ Received
Returns a new instance of Received.
53 54 55 56 |
# File 'lib/internet_message/received.rb', line 53 def initialize(from, by, via, with, id, for_, date) @from, @by, @via, @with, @id, @for, @date = from, by, via, with, id, for_, date end |
Instance Attribute Details
#by ⇒ Object (readonly)
Returns the value of attribute by.
44 45 46 |
# File 'lib/internet_message/received.rb', line 44 def by @by end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
44 45 46 |
# File 'lib/internet_message/received.rb', line 44 def date @date end |
#for ⇒ Object (readonly)
Returns the value of attribute for.
44 45 46 |
# File 'lib/internet_message/received.rb', line 44 def for @for end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
44 45 46 |
# File 'lib/internet_message/received.rb', line 44 def from @from end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
44 45 46 |
# File 'lib/internet_message/received.rb', line 44 def id @id end |
#via ⇒ Object (readonly)
Returns the value of attribute via.
44 45 46 |
# File 'lib/internet_message/received.rb', line 44 def via @via end |
#with ⇒ Object (readonly)
Returns the value of attribute with.
44 45 46 |
# File 'lib/internet_message/received.rb', line 44 def with @with end |
Class Method Details
.parse(src) ⇒ Received
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/internet_message/received.rb', line 8 def self.parse(src) tokens = src.is_a?(String) ? Tokenizer.new(src).tokenize : src.dup i = tokens.index(Token.new(:CHAR, ';')) return unless i date = DateTime.parse(tokens[i+1..-1].join) rescue nil tokens = tokens[0, i] list = tokens.inject([[]]){|r, t| if t.type == :WSP or t.type == :COMMENT r.push [] else r.last.push t end r }.reject(&:empty?) while list.size >= 2 case list.shift.join.downcase when 'from' from = list.shift.join when 'by' by = list.shift.join when 'via' via = list.shift.join when 'with' with = list.shift.join when 'id' id = list.shift.join when 'for' m = Mailbox.parse(list.shift) for_ = m && m.address end end self.new(from, by, via, with, id, for_, date) end |