Skip to content

Instantly share code, notes, and snippets.

@levand
Created May 5, 2011 16:48
Show Gist options
  • Save levand/957402 to your computer and use it in GitHub Desktop.
Save levand/957402 to your computer and use it in GitHub Desktop.
# 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_offset = start_idx % vidaas_count
10 end_offset = start_idx + count
11
12 return {
13 :pages => (first_page...last_page),
14 :indexes => (start_offset..end_offset)
15 }
16
17 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment