Class: HTTY::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/htty/session.rb

Overview

Encapsulates an htty session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address) ⇒ Session

Initializes a new HTTY::Session with specified address for the first of the session’s #requests.



11
12
13
# File 'lib/htty/session.rb', line 11

def initialize(address)
  @requests = [HTTY::Request.new(address)]
end

Instance Attribute Details

#requestsObject (readonly)

Returns the requests made during the session.



7
8
9
# File 'lib/htty/session.rb', line 7

def requests
  @requests
end

Instance Method Details

#last_responseObject

Walks #requests and returns its last HTTY::Response.



16
17
18
19
20
21
22
23
# File 'lib/htty/session.rb', line 16

def last_response
  last_request_with_response = requests.reverse.detect do |r|
    r.response
  end
  return nil unless last_request_with_response

  last_request_with_response.response
end