Class: NasaApi::ResponseHandler::Epic

Inherits:
Object
  • Object
show all
Defined in:
lib/nasa_api/response_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = {}) ⇒ Epic

Returns a new instance of Epic.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/nasa_api/response_handler.rb', line 101

def initialize(response = {})
  @response = response
  response.each do |values|
    (@identifier ||= []) << values['identifier']
    (@caption ||= []) << values['caption']
    (@image ||= []) << values['image']
    (@version ||= []) << values['version']
    (@centroid_coordinates ||= []) << values['centroid_coordinates']
    (@dscovr_j2000_position ||= []) << values['dscovr_j2000_position']
    (@lunar_j2000_position ||= []) << values['lunar_j2000_position']
    (@sun_j2000_position ||= []) << values['sun_j2000_position']
    (@attitude_quaternions ||= []) << values['attitude_quaternions']
    (@date ||= []) << values['date']
    (@coords ||= []) << values['coords']

    # Images are stored in an archive by YYYY/DD/MM url
    # Requires a little extra logic to retrieve image_url
    date_parsed = @date[-1].split(' ')[0]
    parts = date_parsed.split('-')
    (@image_url ||= []) << "https://epic.gsfc.nasa.gov/archive/natural/#{parts[0]}/#{parts[1]}/#{parts[2]}/png/#{@image[-1].to_s}.png"
  end
end

Instance Attribute Details

#attitude_quaternionsObject

Returns the value of attribute attitude_quaternions.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def attitude_quaternions
  @attitude_quaternions
end

#captionObject

Returns the value of attribute caption.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def caption
  @caption
end

#centroid_coordinatesObject

Returns the value of attribute centroid_coordinates.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def centroid_coordinates
  @centroid_coordinates
end

#coordsObject

Returns the value of attribute coords.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def coords
  @coords
end

#dateObject

Returns the value of attribute date.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def date
  @date
end

#dscovr_j2000_positionObject

Returns the value of attribute dscovr_j2000_position.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def dscovr_j2000_position
  @dscovr_j2000_position
end

#identifierObject

Returns the value of attribute identifier.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def identifier
  @identifier
end

#imageObject

Returns the value of attribute image.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def image
  @image
end

#image_urlObject

Returns the value of attribute image_url.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def image_url
  @image_url
end

#lunar_j2000_positionObject

Returns the value of attribute lunar_j2000_position.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def lunar_j2000_position
  @lunar_j2000_position
end

#responseObject

Returns the value of attribute response.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def response
  @response
end

#sun_j2000_positionObject

Returns the value of attribute sun_j2000_position.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def sun_j2000_position
  @sun_j2000_position
end

#versionObject

Returns the value of attribute version.



99
100
101
# File 'lib/nasa_api/response_handler.rb', line 99

def version
  @version
end