class MarsPhotos::API

Attributes

key[R]

Public Class Methods

new(key='DEMO_KEY') click to toggle source
# File lib/mars_photos/api.rb, line 5
def initialize(key='DEMO_KEY')
  @key = key
end

Public Instance Methods

get(params={}) { |photo| ... } click to toggle source
# File lib/mars_photos/api.rb, line 9
def get(params={})
  params[:key] = @key
  url = URL.build(params)
  response = HTTParty.get(url)

  if block_given?
    response['photos'].each { |photo| yield photo }
  end
  response['photos']
end