lib/rails_paginate/pagers/slider.rb in rails_paginate-0.0.4 vs lib/rails_paginate/pagers/slider.rb in rails_paginate-0.0.5

- old
+ new

@@ -1,12 +1,18 @@ module RailsPaginate::Pagers # slider method class Slider < Base - cattr_accessor :inner, :outer + + # how much pages should display around current_page + cattr_accessor :inner @@inner = 3 + + # how much pages should display at start and end + cattr_accessor :outer @@outer = 1 + # build array with all visible pages def visible_pages visible = [] last_inserted = 0 splited = false (1..pages).each do |page| @@ -24,10 +30,11 @@ end end visible end + # build dummy inner range def inner_range @inner_range ||= (current_page - inner)..(current_page + inner) end # looks should this page visible @@ -45,13 +52,15 @@ return true if inner_range.include? page false end + # get option of inner def inner options[:inner] || self.class.inner end + # get option of out def outer options[:outer] || self.class.outer end end \ No newline at end of file