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



116
117
118
# File 'lib/zenrows/backends/net_http.rb', line 116

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



114
115
116
# File 'lib/zenrows/backends/net_http.rb', line 114

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



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

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



131
132
133
# File 'lib/zenrows/backends/net_http.rb', line 131

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



126
127
128
# File 'lib/zenrows/backends/net_http.rb', line 126

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



136
137
138
# File 'lib/zenrows/backends/net_http.rb', line 136

def to_s
  body
end