Class: NasaApod::Client
- Inherits:
-
Object
- Object
- NasaApod::Client
- Defined in:
- lib/nasa_apod/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#date ⇒ Object
Returns the value of attribute date.
-
#list_concepts ⇒ Object
Returns the value of attribute list_concepts.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#search(options = {}) ⇒ NasaApod::SearchResults
Returns APOD info for specified day.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 |
# File 'lib/nasa_apod/client.rb', line 20 def initialize(={}) @api_key = [:api_key] || "DEMO_KEY" self.date = [:date] self.list_concepts = [:list_concepts] end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/nasa_apod/client.rb', line 6 def api_key @api_key end |
#date ⇒ Object
Returns the value of attribute date.
6 7 8 |
# File 'lib/nasa_apod/client.rb', line 6 def date @date end |
#list_concepts ⇒ Object
Returns the value of attribute list_concepts.
6 7 8 |
# File 'lib/nasa_apod/client.rb', line 6 def list_concepts @list_concepts end |
Instance Method Details
#search(options = {}) ⇒ NasaApod::SearchResults
Returns APOD info for specified day.
36 37 38 39 40 41 |
# File 'lib/nasa_apod/client.rb', line 36 def search(={}) self.date = [:date] || date @list_concepts = [:list_concepts] || list_concepts response = HTTParty.get("https://api.nasa.gov/planetary/apod?api_key=#{api_key}&date=#{date}&concept_tags=#{list_concepts}") handle_response(response) end |