Sha256: 2d294a0e4d1b1ad0f2c251655c042481fa8b994b27d9cd2f9392e32a26b40adb

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require 'forwardable'

module Trav3
  class Response
    extend Forwardable
    attr_reader :travis
    def_delegators :@collection, *ResponseCollection.instance_methods.-(Object.methods)
    def_delegators :@response, :code, :code_type, :uri, :message, :read_header,
                   :header, :value, :entity, :response, :body, :decode_content,
                   :msg, :reading_body, :read_body, :http_version,
                   :connection_close?, :connection_keep_alive?,
                   :initialize_http_header, :get_fields, :each_header
    def initialize(travis, response)
      @travis = travis
      @response = response
      @collection = begin
                      result = JSON.parse(response&.body || '{}')
                      ResponseCollection.new(travis, result)
                    rescue JSON::ParserError
                      response.error!
                    end
    end

    def inspect
      "<#{self.class} Response: keys = #{keys}>"
    end

    def success?
      raise Unimplemented
    end

    def failure?
      raise Unimplemented
    end
    private :travis
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
trav3-0.4.1 lib/trav3/response/response.rb
trav3-0.4.0 lib/trav3/response/response.rb
trav3-0.3.4 lib/trav3/response/response.rb
trav3-0.3.3 lib/trav3/response/response.rb
trav3-0.3.2 lib/trav3/response/response.rb
trav3-0.3.1 lib/trav3/response/response.rb