Class: TMail::Address
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#accept_strategy, create_dest, #decoded, #encoded
Constructor Details
#initialize(local, domain) ⇒ Address
Returns a new instance of Address.
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/tmail-pure/address.rb', line 28
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.
40
41
42
|
# File 'lib/tmail-pure/address.rb', line 40
def name
@name
end
|
#routes ⇒ Object
Also known as:
route
Returns the value of attribute routes.
50
51
52
|
# File 'lib/tmail-pure/address.rb', line 50
def routes
@routes
end
|
Class Method Details
.parse(str) ⇒ Object
20
21
22
|
# File 'lib/tmail-pure/address.rb', line 20
def Address.parse(str)
Parser.parse :ADDRESS, str
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
80
81
82
|
# File 'lib/tmail-pure/address.rb', line 80
def ==(other)
other.respond_to? :spec and self.spec == other.spec
end
|
#accept(strategy, dummy1 = nil, dummy2 = nil) ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/tmail-pure/address.rb', line 99
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
24
25
26
|
# File 'lib/tmail-pure/address.rb', line 24
def address_group?
false
end
|
#domain ⇒ Object
62
63
64
65
|
# File 'lib/tmail-pure/address.rb', line 62
def domain
return nil unless @domain
join_domain(@domain)
end
|
#dup ⇒ Object
90
91
92
93
94
95
|
# File 'lib/tmail-pure/address.rb', line 90
def dup
obj = self.class.new(@local.dup, @domain.dup)
obj.name = @name.dup if @name
obj.routes.replace @routes
obj
end
|
#hash ⇒ Object
86
87
88
|
# File 'lib/tmail-pure/address.rb', line 86
def hash
@local.hash ^ @domain.hash
end
|
#inspect ⇒ Object
52
53
54
|
# File 'lib/tmail-pure/address.rb', line 52
def inspect
"#<#{self.class} #{address()}>"
end
|
#local ⇒ Object
56
57
58
59
60
|
# File 'lib/tmail-pure/address.rb', line 56
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
67
68
69
70
71
72
73
74
75
|
# File 'lib/tmail-pure/address.rb', line 67
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=
74
75
76
|
# File 'lib/tmail-pure/obsolete.rb', line 74
def spec=(str)
@local, @domain = str.split(/@/,2).map {|s| s.split(/\./) }
end
|