lib/neat_pages/base.rb in neat-pages-0.1.7 vs lib/neat_pages/base.rb in neat-pages-1.0.0

- old
+ new

@@ -8,17 +8,17 @@ attr_reader :total_items #************************************************************************************* # CONSTRUCTOR #************************************************************************************* - def initialize(current_page, options={}) + def initialize(current_page_param, options={}) options = { per_page: 10, total_items: 0 }.merge(options) @per_page = options[:per_page].to_i @total_items = options[:total_items] - @current_page = init_current_page(current_page) + init_current_page current_page_param @out_of_bound = init_out_of_bound end @@ -87,14 +87,12 @@ private #************************************************************************************* # PRIVATE INSTANCE METHODS #************************************************************************************* - def init_current_page(current_page) - current_page = current_page.to_i - current_page = 1 if current_page == 0 - - return current_page + def init_current_page(current_page_param) + @current_page = current_page_param.to_i + @current_page = 1 if @current_page == 0 end def init_out_of_bound @current_page <= 0 or @current_page > total_pages end