Sha256: acd3b1d03398aea3bf46b6c02707aa2d7bb0e45c91023d7061794ff5aa6be898

Contents?: true

Size: 640 Bytes

Versions: 10

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true

class EzClient::Response
  attr_accessor :http_response, :body

  def initialize(http_response)
    self.http_response = http_response
    self.body = http_response.body.to_s # Make sure we read the body for persistent connection
  end

  def headers
    http_response.headers
  end

  def code
    http_response.code
  end
  alias status code

  def ok?
    code.between?(200, 299)
  end

  def redirect?
    code.between?(300, 399)
  end

  def client_error?
    code.between?(400, 499)
  end

  def server_error?
    code.between?(500, 599)
  end

  def error?
    client_error? || server_error?
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ezclient-0.13.1 lib/ezclient/response.rb
ezclient-0.13.0 lib/ezclient/response.rb
ezclient-0.12.0 lib/ezclient/response.rb
ezclient-0.11.0 lib/ezclient/response.rb
ezclient-0.10.0 lib/ezclient/response.rb
ezclient-0.9.1 lib/ezclient/response.rb
ezclient-0.9.0 lib/ezclient/response.rb
ezclient-0.8.0 lib/ezclient/response.rb
ezclient-0.7.0 lib/ezclient/response.rb
ezclient-0.6.1 lib/ezclient/response.rb