Class: Teamtailor::PageResult

Inherits:
Object
  • Object
show all
Defined in:
lib/teamtailor/page_result.rb

Instance Method Summary collapse

Constructor Details

#initialize(response_body) ⇒ PageResult

Returns a new instance of PageResult.



7
8
9
# File 'lib/teamtailor/page_result.rb', line 7

def initialize(response_body)
  @json_response = JSON.parse(response_body)
end

Instance Method Details

#dataObject



15
16
17
# File 'lib/teamtailor/page_result.rb', line 15

def data
  json_response.dig('data')
end

#first_page_urlObject



31
32
33
# File 'lib/teamtailor/page_result.rb', line 31

def first_page_url
  json_response.dig('links', 'first')
end

#has_next_page?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/teamtailor/page_result.rb', line 39

def has_next_page?
  !next_page_url.nil?
end

#last_page_urlObject



35
36
37
# File 'lib/teamtailor/page_result.rb', line 35

def last_page_url
  json_response.dig('links', 'last')
end

#next_page_urlObject



27
28
29
# File 'lib/teamtailor/page_result.rb', line 27

def next_page_url
  json_response.dig('links', 'next')
end

#page_countObject



19
20
21
# File 'lib/teamtailor/page_result.rb', line 19

def page_count
  json_response.dig('meta', 'page-count')
end

#record_countObject



23
24
25
# File 'lib/teamtailor/page_result.rb', line 23

def record_count
  json_response.dig('meta', 'record-count')
end

#recordsObject



11
12
13
# File 'lib/teamtailor/page_result.rb', line 11

def records
  Teamtailor::Parser.parse json_response
end