lib/page_up/fragment.rb in page_up-0.0.5 vs lib/page_up/fragment.rb in page_up-0.0.6

- old
+ new

@@ -1,12 +1,15 @@ module PageUp class Fragment NullResult = 'NullResult' - def initialize fragment, page, per_page - @page, @per_page = page, per_page + def initialize fragment, page, per_page, total = nil + @page = page + @per_page = per_page + @size = total || (fragment.size + offset) @fragment = [].fill(NullResult, 0, offset) + fragment end + attr_reader :size def [] range until covers? range next_page = page_for(range) result = @callback.call next_page, @per_page