Class: Mail::EnvelopeFromElement

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/mail/elements/envelope_from_element.rb

Constant Summary

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_PREFIX, Patterns::FIELD_SPLIT, Patterns::FWS, Patterns::HEADER_LINE, Patterns::HEADER_SPLIT, Patterns::PHRASE_UNSAFE, Patterns::QP_SAFE, Patterns::QP_UNSAFE, Patterns::TEXT, Patterns::TOKEN_UNSAFE, Patterns::WSP

Instance Method Summary (collapse)

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

- (EnvelopeFromElement) initialize(string)

Returns a new instance of EnvelopeFromElement



7
8
9
10
11
# File 'lib/mail/elements/envelope_from_element.rb', line 7

def initialize( string )
  @envelope_from = Mail::Parsers::EnvelopeFromParser.new.parse(string)
  @address = @envelope_from.address
  @date_time = ::DateTime.parse(@envelope_from.ctime_date)
end

Instance Method Details

- (Object) address



17
18
19
# File 'lib/mail/elements/envelope_from_element.rb', line 17

def address
  @address
end

- (Object) date_time



13
14
15
# File 'lib/mail/elements/envelope_from_element.rb', line 13

def date_time
  @date_time
end

- (Object) formatted_date_time

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);


26
27
28
29
30
31
32
# File 'lib/mail/elements/envelope_from_element.rb', line 26

def formatted_date_time
  if @date_time.respond_to?(:ctime)
    @date_time.ctime
  else
    @date_time.strftime '%a %b %e %T %Y'
  end
end

- (Object) to_s



34
35
36
# File 'lib/mail/elements/envelope_from_element.rb', line 34

def to_s
  "#{@address} #{formatted_date_time}"
end