Sha256: fb2275527396c6a6db642d1b75b30952bb1bcf73278a8e649bbc01b0defbf751
Contents?: true
Size: 727 Bytes
Versions: 27
Compression:
Stored size: 727 Bytes
Contents
require "yajl" module Harpy class EntryPoint attr_accessor :url def initialize(url) self.url = url end def resource_url(resource_type) response = Harpy.client.get url case response.code when 200 body = Yajl::Parser.parse response.body link = (body["link"] || []).detect{|link| link["rel"] == resource_type} link["href"] if link else Harpy.client.invalid_code response end end def urn(urn) response = Harpy.client.get "#{url}/#{urn}" case response.code when 301 response.headers_hash["Location"] when 404 nil else Harpy.client.invalid_code response end end end end
Version data entries
27 entries across 27 versions & 1 rubygems