Sha256: 2c6565bd3f78fc04f6ef600507f07fd6af930d75d2c3857ed4f8e3bfe01a55ef

Contents?: true

Size: 845 Bytes

Versions: 2

Compression:

Stored size: 845 Bytes

Contents

module Richard
  class Request
    attr_reader :verb, :uri, :headers, :body

    def initialize(opts={})
      @verb,@uri,@headers,@body = opts[:verb],opts[:uri],opts[:headers],opts[:body]
    end

    def eql?(other)
      self.verb.eql?(other.verb) && self.uri.eql?(other.uri) && self.headers == other.headers && self.body.eql?(other.body)
    end
  end

  class Response
    attr_reader :status, :headers, :body

    def initialize(opts={})
      @status,@headers,@body = opts[:status],opts[:headers],opts[:body]
    end

    def eql?(other)
      self.status.eql?(other.status) && self.headers == other.headers && self.body.eql?(other.body)
    end

    def each_header(&block)
      self.headers.each_pair{|k,v| block.call(k,v)}
    end
  end

  Status = Struct.new 'Status', :code, :desc do 
    def to_s; "#{code} #{desc}"; end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
richard_iii-0.1.1 lib/richard_iii/request_and_response.rb
richard_iii-0.1.0 lib/richard_iii/request_and_response.rb