[memo] パターンのメモ。

by tanabe on March 08, 2007

net/smtp から抜粋。

def initialize( address, port = nil )
  @address = address
  @port = (port || SMTP.default_port)
  @esmtp = true
  @socket = nil
  @started = false
  @open_timeout = 30
  @read_timeout = 60
  @error_occured = false
  @debug_output = nil
end

def SMTP.start( address, port = nil,
                helo = 'localhost.localdomain',
                user = nil, secret = nil, authtype = nil,
                &block) # :yield: smtp
  new(address, port).start(helo, user, secret, authtype, &block)
end

def start( helo = 'localhost.localdomain',
           user = nil, secret = nil, authtype = nil ) # :yield: smtp
  if block_given?
    begin
      do_start(helo, user, secret, authtype)
      return yield(self)
    ensure
      do_finish
    end
  else
    do_start(helo, user, secret, authtype)
    return self
  end
end