class MarsPhotos::Rover

Attributes

key[RW]
name[RW]

Public Class Methods

new(params = {}) click to toggle source
# File lib/mars_photos/rover.rb, line 6
def initialize(params = {})
  @name = params[:name]
  @key = params[:key] ? params[:key] : 'DEMO_KEY'
end

Public Instance Methods

get(parameters = {}) click to toggle source
# File lib/mars_photos/rover.rb, line 11
def get(parameters = {})
  parameters[:rover] = @name
  parameters[:key] = @key
  url = URL.build(parameters)
  response = HTTParty.get(url)
  response['photos']
end
get_by_earth_date(earth_date) click to toggle source
# File lib/mars_photos/rover.rb, line 25
def get_by_earth_date(earth_date)
  url = URL.build(rover: name, earth_date: earth_date, key: @key)
  response = HTTParty.get(url)
  response['photos']
end
get_by_sol(sol) click to toggle source
# File lib/mars_photos/rover.rb, line 19
def get_by_sol(sol)
  url = URL.build(rover: name, sol: sol, key: @key)
  response = HTTParty.get(url)
  response['photos']
end