Sha256: 0c87436c3eea9e1e9cabd2866831cac290792d67d9420b105660db6024ece249
Contents?: true
Size: 541 Bytes
Versions: 5
Compression:
Stored size: 541 Bytes
Contents
class PaginatedArray < Array attr_reader :total_count, :current_page, :per_page def initialize(total_count, current_page, per_page) @total_count = total_count @current_page = current_page @per_page = per_page super() end def total_page (total_count.fdiv(per_page)).ceil end def next_page next_page = current_page + 1 next_page <= total_page ? next_page : false end def previous_page previous_page = current_page - 1 previous_page > 0 ? previous_page : false end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
lce-0.0.5 | lib/paginated_array.rb |
lce-0.0.4 | lib/paginated_array.rb |
lce-0.0.3 | lib/paginated_array.rb |
lce-0.0.2 | lib/paginated_array.rb |
lce-0.0.1 | lib/paginated_array.rb |