Class: PipeDream::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/pipe_dream/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Response

Returns a new instance of Response.



5
6
7
# File 'lib/pipe_dream/response.rb', line 5

def initialize(data)
  @data = JSON.parse(data)
end

Instance Method Details

#etagObject



13
14
15
# File 'lib/pipe_dream/response.rb', line 13

def etag
  @etag ||= JSON.parse(data.fetch('etag'))
end

#itemsObject



33
34
35
# File 'lib/pipe_dream/response.rb', line 33

def items
  @items ||= data.fetch('items').map { |item| Result.for(item) }
end

#kindObject



9
10
11
# File 'lib/pipe_dream/response.rb', line 9

def kind
  @kind ||= data.fetch('kind')
end

#next_page_tokenObject



17
18
19
# File 'lib/pipe_dream/response.rb', line 17

def next_page_token
  @next_page_token ||= data.fetch('nextPageToken')
end

#region_codeObject



21
22
23
# File 'lib/pipe_dream/response.rb', line 21

def region_code
  @region_code ||= data.fetch('regionCode')
end

#results_per_pageObject



29
30
31
# File 'lib/pipe_dream/response.rb', line 29

def results_per_page
  @results_per_page ||= page_info.fetch('resultsPerPage')
end

#total_resultsObject



25
26
27
# File 'lib/pipe_dream/response.rb', line 25

def total_results
  @total_results ||= page_info.fetch('totalResults')
end