Class: Harpy::EntryPoint
- Inherits:
-
Object
- Object
- Harpy::EntryPoint
- Defined in:
- lib/harpy/entry_point.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ EntryPoint
constructor
A new instance of EntryPoint.
- #resource_url(resource_type) ⇒ Object
- #urn(urn) ⇒ Object
Constructor Details
#initialize(url) ⇒ EntryPoint
Returns a new instance of EntryPoint.
7 8 9 |
# File 'lib/harpy/entry_point.rb', line 7 def initialize(url) self.url = url end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/harpy/entry_point.rb', line 5 def url @url end |
Instance Method Details
#resource_url(resource_type) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/harpy/entry_point.rb', line 11 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 |