Class: TMail::AddressGroup

Inherits:
Object show all
Includes:
Enumerable, StrategyInterface
Defined in:
lib/gems/tmail-1.2.3.1/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.



335
336
337
338
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 335

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

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



342
343
344
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 342

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

#[](idx) ⇒ Object



352
353
354
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 352

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

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



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 406

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



394
395
396
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 394

def add( a )
  @addresses.push a
end

#address_group?Boolean

Returns:

  • (Boolean)


331
332
333
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 331

def address_group?
  true
end

#delete(a) ⇒ Object



400
401
402
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 400

def delete( a )
  @addresses.delete a
end

#each(&block) ⇒ Object



364
365
366
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 364

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

#each_address(&block) ⇒ Object



390
391
392
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 390

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  @addresses.empty?
end

#flattenObject



378
379
380
381
382
383
384
385
386
387
388
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 378

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



348
349
350
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 348

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

#include?(a) ⇒ Boolean

Returns:

  • (Boolean)


374
375
376
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 374

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

#sizeObject



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

def size
  @addresses.size
end

#to_aObject Also known as: to_ary



368
369
370
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/address.rb', line 368

def to_a
  @addresses.dup
end