class NasaApi::ResponseHandler::Apod
Attributes
copyright[RW]
date[RW]
explanation[RW]
hd_url[RW]
media_type[RW]
response[RW]
title[RW]
url[RW]
Public Class Methods
new(response = {})
click to toggle source
# 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