Skip to content

Instantly share code, notes, and snippets.

@pikesley
Last active August 29, 2015 14:11
Show Gist options
  • Save pikesley/22983bff94a671d3a3bc to your computer and use it in GitHub Desktop.
Save pikesley/22983bff94a671d3a3bc to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'httparty'
class Derp
include HTTParty
base_uri 'swapi.co/api'
def initialize(service, page)
@options = { query: {site: service, page: page} }
end
def planets
self.class.get("/planets", @options)
end
end
derp = Derp.new("SWAPI", 1)
puts derp.planets
require 'active_resource'
class Planet < ActiveResource::Base
self.site = "http://swapi.co/api/planets/"
end
Planet.find(1)
@Floppy
Copy link

Floppy commented Dec 22, 2014

I think your root should just be http://swapi.co/api/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment