Sha256: 9817597c2a761ee177feee07e8cc1555ead9bf788e3741803aeb7b4964f23245

Contents?: true

Size: 584 Bytes

Versions: 6

Compression:

Stored size: 584 Bytes

Contents

# frozen_string_literal: true

class EzClient::Response
  attr_accessor :http_response

  def initialize(http_response)
    self.http_response = http_response
  end

  def body
    http_response.body.to_s
  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

6 entries across 6 versions & 1 rubygems

Version Path
ezclient-0.6.0 lib/ezclient/response.rb
ezclient-0.5.0 lib/ezclient/response.rb
ezclient-0.4.0 lib/ezclient/response.rb
ezclient-0.3.0 lib/ezclient/response.rb
ezclient-0.2.0 lib/ezclient/response.rb
ezclient-0.1.0 lib/ezclient/response.rb