class Fog::Compute::DigitalOceanV2::PagingCollection
Public Instance Methods
next_page()
click to toggle source
# File lib/fog/digitalocean/models/paging_collection.rb, line 9 def next_page all(page: @next) if @next != @last end
previous_page()
click to toggle source
# File lib/fog/digitalocean/models/paging_collection.rb, line 13 def previous_page if @next.to_i > 2 all(page: @next.to_i - 2) end end
Private Instance Methods
deep_fetch(hash, *path)
click to toggle source
# File lib/fog/digitalocean/models/paging_collection.rb, line 20 def deep_fetch(hash, *path) path.inject(hash) do |acc, key| acc.respond_to?(:keys) ? acc[key] : nil end end
get_page(link)
click to toggle source
# File lib/fog/digitalocean/models/paging_collection.rb, line 26 def get_page(link) if match = link.match(/page=(?<page>\d+)/) match.captures.last end end
get_paged_links(links)
click to toggle source
# File lib/fog/digitalocean/models/paging_collection.rb, line 32 def get_paged_links(links) next_link = deep_fetch(links, "pages", "next").to_s last_link = deep_fetch(links, "pages", "last").to_s @next = get_page(next_link) || @next @last = get_page(last_link) || @last end