Class: NasaApi::ResponseHandler::Apod
- Inherits:
-
Object
- Object
- NasaApi::ResponseHandler::Apod
- Defined in:
- lib/nasa_api/response_handler.rb
Instance Attribute Summary collapse
-
#copyright ⇒ Object
Returns the value of attribute copyright.
-
#date ⇒ Object
Returns the value of attribute date.
-
#explanation ⇒ Object
Returns the value of attribute explanation.
-
#hd_url ⇒ Object
Returns the value of attribute hd_url.
-
#media_type ⇒ Object
Returns the value of attribute media_type.
-
#response ⇒ Object
Returns the value of attribute response.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(response = {}) ⇒ Apod
constructor
A new instance of Apod.
Constructor Details
#initialize(response = {}) ⇒ Apod
Returns a new instance of Apod.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/nasa_api/response_handler.rb', line 6 def initialize(response = {}) @response = response if response.parsed_response.is_a?(::Hash) @url = response['url'] @hd_url = response['hdurl'] @media_type = response['media_type'] @title = response['title'] @explanation = response['explanation'] @date = response['date'] @copyright = response['copyright'] @service_version = response['service_version'] else # If start_date->end_date is used an array of hashes is returned # Go through every hash and append its response to an array response.each do |values| (@url ||= []) << values['url'] (@hd_url ||= []) << values['hdurl'] (@media_type ||= []) << values['media_type'] (@title ||= []) << values['title'] (@explanation ||= []) << values['explanation'] (@date ||= []) << values['date'] (@copyright ||= []) << values['copyright'] (@service_version ||= []) << values['service_version'] end end end |
Instance Attribute Details
#copyright ⇒ Object
Returns the value of attribute copyright.
4 5 6 |
# File 'lib/nasa_api/response_handler.rb', line 4 def copyright @copyright end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/nasa_api/response_handler.rb', line 4 def date @date end |
#explanation ⇒ Object
Returns the value of attribute explanation.
4 5 6 |
# File 'lib/nasa_api/response_handler.rb', line 4 def explanation @explanation end |
#hd_url ⇒ Object
Returns the value of attribute hd_url.
4 5 6 |
# File 'lib/nasa_api/response_handler.rb', line 4 def hd_url @hd_url end |
#media_type ⇒ Object
Returns the value of attribute media_type.
4 5 6 |
# File 'lib/nasa_api/response_handler.rb', line 4 def media_type @media_type end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/nasa_api/response_handler.rb', line 4 def response @response end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/nasa_api/response_handler.rb', line 4 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/nasa_api/response_handler.rb', line 4 def url @url end |