Module: APIConnector
- Defined in:
- lib/track-r/api_connector/response.rb,
lib/track-r/api_connector/request.rb,
lib/track-r/api_connector/connection.rb
Overview
Generic HTTP wrapper to make calls to the API
Defined Under Namespace
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
Instance Attribute Details
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
4 5 6 |
# File 'lib/track-r/api_connector/connection.rb', line 4 def @error_message end |
#request ⇒ Object
Returns the value of attribute request.
3 4 5 |
# File 'lib/track-r/api_connector/connection.rb', line 3 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/track-r/api_connector/connection.rb', line 3 def response @response end |
Instance Method Details
#connect(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/track-r/api_connector/connection.rb', line 6 def connect(={}) raise(ArgumentError, "You must specify a path to connect to") if !.include?(:path) begin @request = APIConnector::Request.new() @response = @request.connect rescue Timeout::Error @error_message = "Connection timed out" end end |
#error? ⇒ Boolean
16 17 18 |
# File 'lib/track-r/api_connector/connection.rb', line 16 def error? !@error_message.nil? end |