Class: ExploreMars::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/explore_mars/call.rb

Direct Known Subclasses

DateQuery, SolQuery

Constant Summary collapse

CAMERAS =
["FHAZ", "RHAZ", "MAST", "CHEMCAM", "NAVCAM", "MAHLI", "MARDI", "PANCAM", "MINITES"]
BASE_URI =
"https://mars-photos.herokuapp.com/api/v1/rovers/"

Instance Method Summary collapse

Instance Method Details

#getObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/explore_mars/call.rb', line 6

def get
  check_cameras(@camera)
  uri = build_uri
  response = Net::HTTP.get(uri)
  photos = JSON.parse(response)["photos"]
  photos.map { |photo|
    ExploreMars::Photo.new(photo["img_src"], photo["sol"],
                           photo["camera"]["name"], photo["earth_date"],
                           @rover)
  }
end