Skip to content

Instantly share code, notes, and snippets.

@avongluck-r1soft
Created April 29, 2016 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avongluck-r1soft/4500a2279f9fc41be0ca698a2284bfa1 to your computer and use it in GitHub Desktop.
Save avongluck-r1soft/4500a2279f9fc41be0ca698a2284bfa1 to your computer and use it in GitHub Desktop.
module CATApi
@uri = "http://10.80.65.31:57988/r1rmHouston"
def rest_get(path)
begin
response = Faraday.get("#{@uri}#{path}")
return JSON.parse(response.body)
rescue
return nil
end
end
module_function :rest_get
end
module CATApi
class Breed
attr_reader :name
def initialize(attributes)
@name = attributes["Breed"]
end
def self.find(name)
attributes = CATApi.rest_get("/breeds/#{name}")
new(attributes)
end
def self.all
result = CATApi.rest_get("/breeds")
result.map { |name| find(name) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment