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.


301
302
303
304
# File 'lib/tmail/address.rb', line 301

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


306
307
308
# File 'lib/tmail/address.rb', line 306

def name
  @name
end

Instance Method Details

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


308
309
310
# File 'lib/tmail/address.rb', line 308

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

#[](idx) ⇒ Object


318
319
320
# File 'lib/tmail/address.rb', line 318

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

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


372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/tmail/address.rb', line 372

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.puts_meta ','
    end
    strategy.space
    mbox.accept strategy
  end
  strategy.meta ';'
  strategy.lwsp ''
end

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


360
361
362
# File 'lib/tmail/address.rb', line 360

def add( a )
  @addresses.push a
end

#address_group?Boolean

Returns:

  • (Boolean)

297
298
299
# File 'lib/tmail/address.rb', line 297

def address_group?
  true
end

#delete(a) ⇒ Object


366
367
368
# File 'lib/tmail/address.rb', line 366

def delete( a )
  @addresses.delete a
end

#each(&block) ⇒ Object


330
331
332
# File 'lib/tmail/address.rb', line 330

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

#each_address(&block) ⇒ Object


356
357
358
# File 'lib/tmail/address.rb', line 356

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

#empty?Boolean

Returns:

  • (Boolean)

326
327
328
# File 'lib/tmail/address.rb', line 326

def empty?
  @addresses.empty?
end

#flattenObject


344
345
346
347
348
349
350
351
352
353
354
# File 'lib/tmail/address.rb', line 344

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


314
315
316
# File 'lib/tmail/address.rb', line 314

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

#include?(a) ⇒ Boolean

Returns:

  • (Boolean)

340
341
342
# File 'lib/tmail/address.rb', line 340

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

#sizeObject


322
323
324
# File 'lib/tmail/address.rb', line 322

def size
  @addresses.size
end

#to_aObject Also known as: to_ary


334
335
336
# File 'lib/tmail/address.rb', line 334

def to_a
  @addresses.dup
end