Class: KOSapiClient::KOSapiResponse
- Inherits:
-
Object
- Object
- KOSapiClient::KOSapiResponse
- Defined in:
- lib/kosapi_client/kosapi_response.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
Instance Method Summary collapse
-
#initialize(contents) ⇒ KOSapiResponse
constructor
A new instance of KOSapiResponse.
- #is_paginated? ⇒ Boolean
- #item ⇒ Object
- #items ⇒ Object
- #links_hash ⇒ Object
Constructor Details
#initialize(contents) ⇒ KOSapiResponse
Returns a new instance of KOSapiResponse.
6 7 8 |
# File 'lib/kosapi_client/kosapi_response.rb', line 6 def initialize(contents) @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
4 5 6 |
# File 'lib/kosapi_client/kosapi_response.rb', line 4 def contents @contents end |
Instance Method Details
#is_paginated? ⇒ Boolean
10 11 12 |
# File 'lib/kosapi_client/kosapi_response.rb', line 10 def is_paginated? contents[:atom_feed] end |
#item ⇒ Object
22 23 24 |
# File 'lib/kosapi_client/kosapi_response.rb', line 22 def item items.first end |
#items ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/kosapi_client/kosapi_response.rb', line 14 def items if is_paginated? contents[:atom_feed][:atom_entry] else [contents[:atom_entry]] end end |
#links_hash ⇒ Object
26 27 28 29 |
# File 'lib/kosapi_client/kosapi_response.rb', line 26 def links_hash return nil unless contents[:atom_feed] contents[:atom_feed][:atom_link] end |