Skip to content

Instantly share code, notes, and snippets.

@levand
Created May 5, 2011 16:56
Show Gist options
  • Save levand/957414 to your computer and use it in GitHub Desktop.
Save levand/957414 to your computer and use it in GitHub Desktop.
1 # all indexes are 0-based
2 def page_map(page, count, vidaas_count = 20)
3
4 start_idx = page * count
5
6 first_page = start_idx / vidaas_count
7 last_page = first_page + (count / vidaas_count)
8
9 start_subset = start_idx % vidaas_count
10 end_subset = start_subset + count
11
12 return {
13 :pages => (first_page...last_page),
14 :indexes => (start_subset..end_subset)
15 }
16
17 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment