Class: ResponseHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/handlers/response_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(responseQueue) ⇒ ResponseHandler

Returns a new instance of ResponseHandler.



7
8
9
# File 'lib/handlers/response_handler.rb', line 7

def initialize(responseQueue)
  @responseHash = queueToHash(responseQueue)
end

Instance Attribute Details

#responseHashObject (readonly)

Returns the value of attribute responseHash.



4
5
6
# File 'lib/handlers/response_handler.rb', line 4

def responseHash
  @responseHash
end

Instance Method Details

#clearResponseHashObject



19
20
21
# File 'lib/handlers/response_handler.rb', line 19

def clearResponseHash
  @responseHash.clear
end

#getResponsesByURI(uri) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/handlers/response_handler.rb', line 25

def getResponsesByURI(uri)
  returnHash = Hash.new
  @responseHash.each do |index,value|
    if value.getRequestURI.to_s.casecmp(uri)
      returnHash[index] = value
    end
  end
  returnHash
end

#listResponsesObject



41
42
43
44
45
46
# File 'lib/handlers/response_handler.rb', line 41

def listResponses
  @responseHash.each do |key,value|
    puts "Request ID: #{key} had a response code of #{value.code}, response body of #{value.body}, response message of #{value.msg}"
    puts "For URI: #{value.getRequestURI}, and Post Body: #{value.getPostBody}"
  end
end

#updateHash(queue) ⇒ Object



13
14
15
# File 'lib/handlers/response_handler.rb', line 13

def updateHash(queue)
  @responseHash = queueToHash(queue).merge(@responseHash)
end