Class: Zenrows::Backends::NetHttpResponse Private

Inherits:
Object
  • Object
show all
Defined in:
lib/zenrows/backends/net_http.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Response wrapper that mimics http.rb response interface

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ NetHttpResponse

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NetHttpResponse.

Since:

  • 0.1.0



124
125
126
# File 'lib/zenrows/backends/net_http.rb', line 124

def initialize(response)
  @raw = response
end

Instance Attribute Details

#rawNet::HTTPResponse (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Raw response.

Returns:

  • (Net::HTTPResponse)

    Raw response

Since:

  • 0.1.0



122
123
124
# File 'lib/zenrows/backends/net_http.rb', line 122

def raw
  @raw
end

Instance Method Details

#bodyString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Response body.

Returns:

  • (String)

    Response body

Since:

  • 0.1.0



129
130
131
# File 'lib/zenrows/backends/net_http.rb', line 129

def body
  @raw.body
end

#headersHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Response headers.

Returns:

  • (Hash)

    Response headers

Since:

  • 0.1.0



139
140
141
# File 'lib/zenrows/backends/net_http.rb', line 139

def headers
  @raw.to_hash.transform_values(&:first)
end

#statusInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns HTTP status code.

Returns:

  • (Integer)

    HTTP status code

Since:

  • 0.1.0



134
135
136
# File 'lib/zenrows/backends/net_http.rb', line 134

def status
  @raw.code.to_i
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Alias for body (http.rb compatibility)

Since:

  • 0.1.0



144
145
146
# File 'lib/zenrows/backends/net_http.rb', line 144

def to_s
  body
end