Class: TMail::AddressGroup

Inherits:
Object show all
Includes:
Enumerable, StrategyInterface
Defined in:
lib/tmail/address.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StrategyInterface

#accept_strategy, create_dest, #decoded, #encoded

Methods included from Enumerable

#reject, #sort_by

Constructor Details

#initialize(name, addrs) ⇒ AddressGroup

Returns a new instance of AddressGroup.



154
155
156
157
# File 'lib/tmail/address.rb', line 154

def initialize( name, addrs )
  @name = name
  @addresses = addrs
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



159
160
161
# File 'lib/tmail/address.rb', line 159

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



161
162
163
# File 'lib/tmail/address.rb', line 161

def ==( other )
  other.respond_to? :to_a and @addresses == other.to_a
end

#[](idx) ⇒ Object



171
172
173
# File 'lib/tmail/address.rb', line 171

def []( idx )
  @addresses[idx]
end

#accept(strategy, dummy1 = nil, dummy2 = nil) ⇒ Object



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/tmail/address.rb', line 225

def accept( strategy, dummy1 = nil, dummy2 = nil )
  strategy.phrase @name
  strategy.meta ':'
  strategy.space
  first = true
  each do |mbox|
    if first
      first = false
    else
      strategy.meta ','
    end
    strategy.space
    mbox.accept strategy
  end
  strategy.meta ';'
  strategy.lwsp ''
end

#add(a) ⇒ Object Also known as: push



213
214
215
# File 'lib/tmail/address.rb', line 213

def add( a )
  @addresses.push a
end

#address_group?Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/tmail/address.rb', line 150

def address_group?
  true
end

#delete(a) ⇒ Object



219
220
221
# File 'lib/tmail/address.rb', line 219

def delete( a )
  @addresses.delete a
end

#each(&block) ⇒ Object



183
184
185
# File 'lib/tmail/address.rb', line 183

def each( &block )
  @addresses.each(&block)
end

#each_address(&block) ⇒ Object



209
210
211
# File 'lib/tmail/address.rb', line 209

def each_address( &block )
  flatten.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


179
180
181
# File 'lib/tmail/address.rb', line 179

def empty?
  @addresses.empty?
end

#flattenObject



197
198
199
200
201
202
203
204
205
206
207
# File 'lib/tmail/address.rb', line 197

def flatten
  set = []
  @addresses.each do |a|
    if a.respond_to? :flatten
      set.concat a.flatten
    else
      set.push a
    end
  end
  set
end

#hashObject



167
168
169
# File 'lib/tmail/address.rb', line 167

def hash
  map {|i| i.hash }.hash
end

#include?(a) ⇒ Boolean

Returns:

  • (Boolean)


193
194
195
# File 'lib/tmail/address.rb', line 193

def include?( a )
  @addresses.include? a
end

#sizeObject



175
176
177
# File 'lib/tmail/address.rb', line 175

def size
  @addresses.size
end

#to_aObject Also known as: to_ary



187
188
189
# File 'lib/tmail/address.rb', line 187

def to_a
  @addresses.dup
end