Class: Dirigible::DeviceInformation::List

Inherits:
Object
  • Object
show all
Defined in:
lib/dirigible/device_information.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ List

Returns a new instance of List.



103
104
105
# File 'lib/dirigible/device_information.rb', line 103

def initialize(response)
  @response = response
end

Instance Method Details

#[](value) ⇒ Object



107
108
109
# File 'lib/dirigible/device_information.rb', line 107

def [](value)
  @response[value]
end

#next_page(params = {}) ⇒ Object

Fetch the next page for this device listing. Returns nil if next_page is nil.



113
114
115
116
117
118
119
120
# File 'lib/dirigible/device_information.rb', line 113

def next_page(params = {})
  return nil if @response[:next_page].nil?
  uri = URI.parse(@response[:next_page])
  path = "/#{uri.path.gsub(/\/api\/|\//, '')}"
  # Shew! Need to simplify this!
  params = (CGI.parse(uri.query).map{ |k,v| { k => v[0] } }.reduce({}) { |h,pairs| pairs.each { |k,v| (h[k.to_sym] = v) }; h }).merge!(params)
  List.new(Dirigible.get(path, params))
end