Class: TMail::Address
Overview
Constant Summary
Constants included
from TextUtils
TextUtils::ATOM_UNSAFE, TextUtils::CONTROL_CHAR, TextUtils::MESSAGE_ID, TextUtils::MIME_ENCODED, TextUtils::MONTH, TextUtils::NKF_FLAGS, TextUtils::PHRASE_UNSAFE, TextUtils::RFC2231_ENCODED, TextUtils::TOKEN_UNSAFE, TextUtils::WDAY, TextUtils::ZONESTR_TABLE
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#accept_strategy, create_dest, #decoded, #encoded
Methods included from TextUtils
#atom_safe?, #decode_RFC2231, #decode_params, #join_domain, #message_id?, #mime_encoded?, #quote_atom, #quote_phrase, #quote_token, #time2str, #timezone_string_to_unixtime, #to_kcode, #token_safe?
Constructor Details
#initialize(local, domain) ⇒ Address
Returns a new instance of Address.
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 29
def initialize( local, domain )
if domain
domain.each do |s|
raise SyntaxError, 'empty word in domain' if s.empty?
end
end
@local = local
@domain = domain
@name = nil
@routes = []
end
|
Instance Attribute Details
#name ⇒ Object
Also known as:
phrase
Returns the value of attribute name.
41
42
43
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 41
def name
@name
end
|
#routes ⇒ Object
Also known as:
route
Returns the value of attribute routes.
51
52
53
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 51
def routes
@routes
end
|
Class Method Details
.parse(str) ⇒ Object
21
22
23
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 21
def Address.parse( str )
Parser.parse :ADDRESS, str
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
81
82
83
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 81
def ==( other )
other.respond_to? :spec and self.spec == other.spec
end
|
#accept(strategy, dummy1 = nil, dummy2 = nil) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 100
def accept( strategy, dummy1 = nil, dummy2 = nil )
unless @local
strategy.meta '<>' return
end
spec_p = (not @name and @routes.empty?)
if @name
strategy.phrase @name
strategy.space
end
tmp = spec_p ? '' : '<'
unless @routes.empty?
tmp << @routes.map {|i| '@' + i }.join(',') << ':'
end
tmp << self.spec
tmp << '>' unless spec_p
strategy.meta tmp
strategy.lwsp ''
end
|
#address_group? ⇒ Boolean
25
26
27
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 25
def address_group?
false
end
|
#domain ⇒ Object
63
64
65
66
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 63
def domain
return nil unless @domain
join_domain(@domain)
end
|
#dup ⇒ Object
91
92
93
94
95
96
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 91
def dup
obj = self.class.new(@local.dup, @domain.dup)
obj.name = @name.dup if @name
obj.routes.replace @routes
obj
end
|
#hash ⇒ Object
87
88
89
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 87
def hash
@local.hash ^ @domain.hash
end
|
#inspect ⇒ Object
53
54
55
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 53
def inspect
"#<#{self.class} #{address()}>"
end
|
#local ⇒ Object
57
58
59
60
61
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 57
def local
return nil unless @local
return '""' if @local.size == 1 and @local[0].empty?
@local.map {|i| quote_atom(i) }.join('.')
end
|
#spec ⇒ Object
Also known as:
address, addr
68
69
70
71
72
73
74
75
76
|
# File 'lib/action_mailer/vendor/tmail/address.rb', line 68
def spec
s = self.local
d = self.domain
if s and d
s + '@' + d
else
s
end
end
|
#spec=(str) ⇒ Object
Also known as:
addr=, address=
71
72
73
|
# File 'lib/action_mailer/vendor/tmail/obsolete.rb', line 71
def spec=( str )
@local, @domain = str.split(/@/,2).map {|s| s.split(/\./) }
end
|