module Swapi
Constants
- BASE_URL
- FILMS
- PEOPLE
- PLANETS
- SPECIES
- STARSHIPS
- VEHICLES
Public Class Methods
get_all(type)
click to toggle source
# File lib/swapi.rb, line 13 def get_all(type) get type end
get_film(film_id)
click to toggle source
# File lib/swapi.rb, line 37 def get_film(film_id) get FILMS, film_id end
get_person(people_id)
click to toggle source
# File lib/swapi.rb, line 21 def get_person(people_id) get PEOPLE, people_id end
get_planet(planet_id)
click to toggle source
# File lib/swapi.rb, line 17 def get_planet(planet_id) get PLANETS, planet_id end
get_species(species_id)
click to toggle source
# File lib/swapi.rb, line 33 def get_species(species_id) get SPECIES, species_id end
get_starship(starship_id)
click to toggle source
# File lib/swapi.rb, line 25 def get_starship(starship_id) get STARSHIPS, starship_id end
get_vehicle(vehicle_id)
click to toggle source
# File lib/swapi.rb, line 29 def get_vehicle(vehicle_id) get VEHICLES, vehicle_id end
Private Class Methods
execute_request(uri)
click to toggle source
# File lib/swapi.rb, line 47 def execute_request(uri) response = open("#{BASE_URL}/#{uri}", "User-Agent" => "swapi-ruby").read end
get(type, id = '')
click to toggle source
# File lib/swapi.rb, line 43 def get(type, id = '') response = execute_request("#{type}/#{id}") end