Class: Hyperquest::Response

Inherits:
OpenStruct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hyperquest/response.rb

Overview

Hyperquest::Response is a wrapper for responses from hyperquest.go

Attributes collapse

Attributes collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Response

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.

Instantiated by Hyperquest::Request - see Hyperquest::Request.open

Parameters:

  • hash (Hash)

    Parsed JSON



14
15
16
# File 'lib/hyperquest/response.rb', line 14

def initialize(hash)
  @response = OpenStruct.new(hash).freeze
end

Instance Attribute Details

#bodyString (readonly)

Returns:

  • (String)


31
32
33
# File 'lib/hyperquest/response.rb', line 31

def_delegators :@response,
:uri, :content_length, :content_type,
:body, :status, :error

#content_lengthFixnum (readonly)

Returns:

  • (Fixnum)


31
32
33
# File 'lib/hyperquest/response.rb', line 31

def_delegators :@response,
:uri, :content_length, :content_type,
:body, :status, :error

#content_typeString (readonly)

Returns:

  • (String)


31
32
33
# File 'lib/hyperquest/response.rb', line 31

def_delegators :@response,
:uri, :content_length, :content_type,
:body, :status, :error

#errorString (readonly)

Returns:

  • (String)


31
32
33
# File 'lib/hyperquest/response.rb', line 31

def_delegators :@response,
:uri, :content_length, :content_type,
:body, :status, :error

#statusFixnum (readonly)

Returns:

  • (Fixnum)


31
32
33
# File 'lib/hyperquest/response.rb', line 31

def_delegators :@response,
:uri, :content_length, :content_type,
:body, :status, :error

#uriString (readonly)

Returns Request url.

Returns:

  • (String)

    Request url



31
32
33
# File 'lib/hyperquest/response.rb', line 31

def_delegators :@response,
:uri, :content_length, :content_type,
:body, :status, :error

Instance Method Details

#failed?Boolean

Returns true if error is not empty

Returns:

  • (Boolean)


43
44
45
# File 'lib/hyperquest/response.rb', line 43

def failed?
  !success?
end

#success?Boolean

Returns true if error is empty

Returns:

  • (Boolean)


37
38
39
# File 'lib/hyperquest/response.rb', line 37

def success?
  error.empty?
end