Class: Mail::EnvelopeFromElement
- Includes:
- Utilities
- Defined in:
- lib/mail/elements/envelope_from_element.rb
Constant Summary
Constants included from Patterns
Patterns::ATOM_UNSAFE, Patterns::CONTROL_CHAR, Patterns::CRLF, Patterns::FIELD_BODY, Patterns::FIELD_LINE, Patterns::FIELD_NAME, Patterns::FIELD_SPLIT, Patterns::FWS, Patterns::HEADER_LINE, Patterns::PHRASE_UNSAFE, Patterns::QP_SAFE, Patterns::QP_UNSAFE, Patterns::TEXT, Patterns::TOKEN_UNSAFE, Patterns::WSP
Instance Method Summary collapse
- #address ⇒ Object
- #date_time ⇒ Object
-
#formatted_date_time ⇒ Object
RFC 4155: a timestamp indicating the UTC date and time when the message was originally received, conformant with the syntax of the traditional UNIX ‘ctime’ output sans timezone (note that the use of UTC precludes the need for a timezone indicator);.
-
#initialize(string) ⇒ EnvelopeFromElement
constructor
A new instance of EnvelopeFromElement.
- #to_s ⇒ Object
- #tree ⇒ Object
Methods included from Utilities
#atom_safe?, #bracket, #capitalize_field, #constantize, #dasherize, #dquote, #escape_paren, #map_lines, #map_with_index, #match_to_s, #paren, #quote_atom, #quote_phrase, #quote_token, #token_safe?, #unbracket, #underscoreize, #unparen, #unquote, #uri_escape, #uri_parser, #uri_unescape
Constructor Details
#initialize(string) ⇒ EnvelopeFromElement
Returns a new instance of EnvelopeFromElement.
7 8 9 10 11 12 13 14 15 |
# File 'lib/mail/elements/envelope_from_element.rb', line 7 def initialize( string ) parser = Mail::EnvelopeFromParser.new if @tree = parser.parse(string) @address = tree.addr_spec.text_value.strip @date_time = ::DateTime.parse("#{tree.ctime_date.text_value}") else raise Mail::Field::ParseError.new(EnvelopeFromElement, string, parser.failure_reason) end end |
Instance Method Details
#address ⇒ Object
25 26 27 |
# File 'lib/mail/elements/envelope_from_element.rb', line 25 def address @address end |
#date_time ⇒ Object
21 22 23 |
# File 'lib/mail/elements/envelope_from_element.rb', line 21 def date_time @date_time end |
#formatted_date_time ⇒ Object
RFC 4155:
a timestamp indicating the UTC date and time when the message
was originally received, conformant with the syntax of the
traditional UNIX 'ctime' output sans timezone (note that the
use of UTC precludes the need for a timezone indicator);
34 35 36 37 38 39 40 |
# File 'lib/mail/elements/envelope_from_element.rb', line 34 def formatted_date_time if @date_time.respond_to?(:ctime) @date_time.ctime else @date_time.strftime '%a %b %e %T %Y' end end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/mail/elements/envelope_from_element.rb', line 42 def to_s "#{@address} #{formatted_date_time}" end |
#tree ⇒ Object
17 18 19 |
# File 'lib/mail/elements/envelope_from_element.rb', line 17 def tree @tree end |