Class: Nsa::NetHttpTracker
- Inherits:
-
Object
- Object
- Nsa::NetHttpTracker
- Defined in:
- lib/nsa/net_http_tracker.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#request_body ⇒ Object
readonly
Returns the value of attribute request_body.
-
#request_headers ⇒ Object
readonly
Returns the value of attribute request_headers.
-
#response_body ⇒ Object
Returns the value of attribute response_body.
-
#response_headers ⇒ Object
readonly
Returns the value of attribute response_headers.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
-
#status_message ⇒ Object
readonly
Returns the value of attribute status_message.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(protocol, address, port, path, method, headers, body) ⇒ NetHttpTracker
constructor
A new instance of NetHttpTracker.
- #on_body(&block) ⇒ Object
- #on_response(&block) ⇒ Object
- #set_response_info(status_code, status_message, headers) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(protocol, address, port, path, method, headers, body) ⇒ NetHttpTracker
Returns a new instance of NetHttpTracker.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/nsa/net_http_tracker.rb', line 19 def initialize(protocol, address, port, path, method, headers, body) @protocol = protocol @address = address @port = port @path = path @method = method @request_headers = headers @request_body = body self.class.on_request.call(self) end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def address @address end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def port @port end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def protocol @protocol end |
#request_body ⇒ Object (readonly)
Returns the value of attribute request_body.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def request_body @request_body end |
#request_headers ⇒ Object (readonly)
Returns the value of attribute request_headers.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def request_headers @request_headers end |
#response_body ⇒ Object
Returns the value of attribute response_body.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def response_body @response_body end |
#response_headers ⇒ Object (readonly)
Returns the value of attribute response_headers.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def response_headers @response_headers end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def status_code @status_code end |
#status_message ⇒ Object (readonly)
Returns the value of attribute status_message.
15 16 17 |
# File 'lib/nsa/net_http_tracker.rb', line 15 def @status_message end |
Class Method Details
.on_request(&block) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/nsa/net_http_tracker.rb', line 6 def on_request(&block) if block_given? @on_request = block else @on_request end end |
Instance Method Details
#on_body(&block) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/nsa/net_http_tracker.rb', line 42 def on_body(&block) if block_given? @on_body = block else @on_body end end |
#on_response(&block) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/nsa/net_http_tracker.rb', line 34 def on_response(&block) if block_given? @on_response = block else @on_response end end |
#set_response_info(status_code, status_message, headers) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/nsa/net_http_tracker.rb', line 50 def set_response_info(status_code, , headers) @status_code = status_code @status_message = @response_headers = headers on_response.call end |
#url ⇒ Object
30 31 32 |
# File 'lib/nsa/net_http_tracker.rb', line 30 def url "#{protocol}://#{address}#{path}" end |