Skip to content

Instantly share code, notes, and snippets.

@cmar
Created September 14, 2015 19:48
Show Gist options
  • Save cmar/2bc19fd1a31fd5e8a3de to your computer and use it in GitHub Desktop.
Save cmar/2bc19fd1a31fd5e8a3de to your computer and use it in GitHub Desktop.
RubyLoCo Star Wars Hack Night Example
#! /usr/bin/env ruby
# RubyLoCo Star Wars Hack Night
# Documentation https://swapi.co/documentation
require 'bundler/inline'
# true to install gems
gemfile false do
source 'https://rubygems.org'
gem 'httparty'
end
class StarWars
include HTTParty
base_uri 'swapi.co/api'
def people(id)
response = self.class.get("/people/#{id}")
response.parsed_response
end
end
star_wars = StarWars.new
luke = star_wars.people(1)
p luke["name"]
p luke["films"]
p StarWars.get(luke["films"].first).parsed_response["title"]
@bjmllr
Copy link

bjmllr commented Sep 14, 2015

i tried my hand at porting this example & then fleshing it out into a client library in crystal, here's how far i got: https://gist.github.com/bjmllr/a366d137f0d52d95f405

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