Class: Net::SMTP::Response

Inherits:
Object show all
Defined in:
lib/net/smtp.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Response) initialize(status, string)

A new instance of Response



981
982
983
984
# File 'lib/net/smtp.rb', line 981

def initialize(status, string)
  @status = status
  @string = string
end

Instance Attribute Details

- (Object) status (readonly)

Returns the value of attribute status



986
987
988
# File 'lib/net/smtp.rb', line 986

def status
  @status
end

- (Object) string (readonly)

Returns the value of attribute string



987
988
989
# File 'lib/net/smtp.rb', line 987

def string
  @string
end

Class Method Details

+ (Object) parse(str)



977
978
979
# File 'lib/net/smtp.rb', line 977

def Response.parse(str)
  new(str[0,3], str)
end

Instance Method Details

- (Object) capabilities



1009
1010
1011
1012
1013
1014
1015
1016
1017
# File 'lib/net/smtp.rb', line 1009

def capabilities
  return {} unless @string[3, 1] == '-'
  h = {}
  @string.lines.drop(1).each do |line|
    k, *v = line[4..-1].chomp.split(nil)
    h[k] = v
  end
  h
end

- (Boolean) continue?

Returns:

  • (Boolean)


997
998
999
# File 'lib/net/smtp.rb', line 997

def continue?
  status_type_char() == '3'
end

- (Object) cram_md5_challenge



1005
1006
1007
# File 'lib/net/smtp.rb', line 1005

def cram_md5_challenge
  @string.split(/ /)[1].unpack('m')[0]
end

- (Object) exception_class



1019
1020
1021
1022
1023
1024
1025
1026
1027
# File 'lib/net/smtp.rb', line 1019

def exception_class
  case @status
  when /\A4/  then SMTPServerBusy
  when /\A50/ then SMTPSyntaxError
  when /\A53/ then SMTPAuthenticationError
  when /\A5/  then SMTPFatalError
  else             SMTPUnknownError
  end
end

- (Object) message



1001
1002
1003
# File 'lib/net/smtp.rb', line 1001

def message
  @string.lines.first
end

- (Object) status_type_char



989
990
991
# File 'lib/net/smtp.rb', line 989

def status_type_char
  @status[0, 1]
end

- (Boolean) success?

Returns:

  • (Boolean)


993
994
995
# File 'lib/net/smtp.rb', line 993

def success?
  status_type_char() == '2'
end