Class TMail::Address
In: lib/tmail/address.rb
lib/tmail/obsolete.rb
Parent: Object

address.rb

Methods

==   accept   addr   addr=   address   address=   address_group?   domain   dup   eql?   hash   inspect   local   name=   new   parse   phrase=   spec   spec=  

Included Modules

TextUtils StrategyInterface

External Aliases

name -> phrase
routes -> route

Attributes

name  [R] 
routes  [R] 

Public Class methods

[Source]

# File lib/tmail/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

[Source]

# File lib/tmail/address.rb, line 20
    def Address.parse(str)
      Parser.parse :ADDRESS, str
    end

Public Instance methods

[Source]

# File lib/tmail/address.rb, line 80
    def ==(other)
      other.respond_to? :spec and self.spec == other.spec
    end

[Source]

# File lib/tmail/address.rb, line 99
    def accept(strategy, dummy1 = nil, dummy2 = nil)
      unless @local
        strategy.meta '<>'   # empty return-path
        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
addr()

Alias for spec

addr=(str)

Alias for spec=

address()

Alias for spec

address=(str)

Alias for spec=

[Source]

# File lib/tmail/address.rb, line 24
    def address_group?
      false
    end

[Source]

# File lib/tmail/address.rb, line 62
    def domain
      return nil unless @domain
      join_domain(@domain)
    end

[Source]

# File lib/tmail/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
eql?(other)

Alias for #==

[Source]

# File lib/tmail/address.rb, line 86
    def hash
      @local.hash ^ @domain.hash
    end

[Source]

# File lib/tmail/address.rb, line 52
    def inspect
      "#<#{self.class} #{address()}>"
    end

[Source]

# File lib/tmail/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

[Source]

# File lib/tmail/address.rb, line 42
    def name=(str)
      @name = str
      @name = nil if str and str.empty?
    end
phrase=(str)

Alias for name=

[Source]

# File lib/tmail/address.rb, line 67
    def spec
      s = self.local
      d = self.domain
      if s and d
        s + '@' + d
      else
        s
      end
    end

[Source]

# File lib/tmail/obsolete.rb, line 73
    def spec=(str)
      @local, @domain = str.split(/@/,2).map {|s| s.split(/\./) }
    end

[Validate]