Class: Request
- Inherits:
-
Object
- Object
- Request
- Defined in:
- lib/flight_radar/request.rb
Overview
The Request
class handles making HTTP requests using the HTTParty gem.
Instance Method Summary collapse
-
#content ⇒ Hash
Returns the parsed content of the HTTP response.
-
#content_type ⇒ String
Returns the content type of the HTTP response.
-
#initialize(url, headers = {}, params = {}) ⇒ Request
constructor
Initializes a new instance of the
Request
class. -
#status_code ⇒ Integer
Returns the status code of the HTTP response.
-
#success? ⇒ Boolean
Checks if the HTTP response code indicates success.
Constructor Details
#initialize(url, headers = {}, params = {}) ⇒ Request
Initializes a new instance of the Request
class.
12 13 14 15 16 17 18 19 |
# File 'lib/flight_radar/request.rb', line 12 def initialize(url, headers = {}, params = {}) @url = url @params = params @headers = headers @lang = 'en' @response = send_request(url, headers, params) end |
Instance Method Details
#content ⇒ Hash
Returns the parsed content of the HTTP response.
24 25 26 |
# File 'lib/flight_radar/request.rb', line 24 def content @response.parsed_response end |
#content_type ⇒ String
Returns the content type of the HTTP response.
31 32 33 |
# File 'lib/flight_radar/request.rb', line 31 def content_type @response.content_type end |
#status_code ⇒ Integer
Returns the status code of the HTTP response.
38 39 40 |
# File 'lib/flight_radar/request.rb', line 38 def status_code @response.code end |
#success? ⇒ Boolean
Checks if the HTTP response code indicates success.
45 46 47 |
# File 'lib/flight_radar/request.rb', line 45 def success? (200..299).include?(@response.code) end |