Class: Net::SMTP::Response

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, string) ⇒ Response

Returns a new instance of Response.



957
958
959
960
# File 'lib/net/smtp.rb', line 957

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

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



962
963
964
# File 'lib/net/smtp.rb', line 962

def status
  @status
end

#stringObject (readonly)

Returns the value of attribute string.



963
964
965
# File 'lib/net/smtp.rb', line 963

def string
  @string
end

Class Method Details

.parse(str) ⇒ Object



953
954
955
# File 'lib/net/smtp.rb', line 953

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

Instance Method Details

#capabilitiesObject



985
986
987
988
989
990
991
992
993
# File 'lib/net/smtp.rb', line 985

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

#continue?Boolean

Returns:

  • (Boolean)


973
974
975
# File 'lib/net/smtp.rb', line 973

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

#cram_md5_challengeObject



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

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

#exception_classObject



995
996
997
998
999
1000
1001
1002
1003
# File 'lib/net/smtp.rb', line 995

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

#messageObject



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

def message
  @string.lines.first
end

#status_type_charObject



965
966
967
# File 'lib/net/smtp.rb', line 965

def status_type_char
  @status[0, 1]
end

#success?Boolean

Returns:

  • (Boolean)


969
970
971
# File 'lib/net/smtp.rb', line 969

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