Class: KOSapiClient::KOSapiResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/kosapi_client/kosapi_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentsObject (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

Returns:

  • (Boolean)


10
11
12
# File 'lib/kosapi_client/kosapi_response.rb', line 10

def is_paginated?
  contents[:atom_feed]
end

#itemObject



22
23
24
# File 'lib/kosapi_client/kosapi_response.rb', line 22

def item
  items.first
end

#itemsObject



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


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