class Rubhttp::Response::Status

Constants

REASONS

Attributes

code[R]

@return [Fixnum] status code

Public Class Methods

new(code) click to toggle source

@param code [Fixnum]

# File lib/rubhttp/response/status.rb, line 72
def initialize(code)
  @code = code
end

Public Instance Methods

client_error?() click to toggle source

Check if status code is client error (4XX).

@return [Boolean]

# File lib/rubhttp/response/status.rb, line 106
def client_error?
  code >= 400 && code < 500
end
informational?() click to toggle source

Check if status code is informational (1XX).

@return [Boolean]

# File lib/rubhttp/response/status.rb, line 85
def informational?
  code >= 100 && code < 200
end
inspect() click to toggle source

Printable version of HTTP Status, surrounded by quote marks, with special characters escaped.

@return [String]

# File lib/rubhttp/response/status.rb, line 126
def inspect
  "#<#{self.class} #{self}>"
end
reason() click to toggle source

@see REASONS @return [String, nil] status message

# File lib/rubhttp/response/status.rb, line 78
def reason
  REASONS[code]
end
redirect?() click to toggle source

Check if status code is redirection (3XX).

@return [Boolean]

# File lib/rubhttp/response/status.rb, line 99
def redirect?
  code >= 300 && code < 400
end
server_error?() click to toggle source

Check if status code is server error (5XX).

@return [Boolean]

# File lib/rubhttp/response/status.rb, line 113
def server_error?
  code >= 500 && code < 600
end
success?() click to toggle source

Check if status code is successful (2XX).

@return [Boolean]

# File lib/rubhttp/response/status.rb, line 92
def success?
  code >= 200 && code < 300
end
to_s() click to toggle source

@return [String] string representation of HTTP status

# File lib/rubhttp/response/status.rb, line 118
def to_s
  "#{code} #{reason}".strip
end