Class: WillPaginate::PageNumber

### Home Classes Methods

### In Files

- lib/will_paginate/page_number.rb

### Parent

DelegateClass(Integer)

### Methods

- ::new
- #inspect
- #is_a?
- #kind_of?
- #to_offset

### Class/Module Index

Quicksearch

- WillPaginate
- WillPaginate::ActionView
- WillPaginate::ActionView::LinkRenderer
- WillPaginate::ActiveRecord
- WillPaginate::ActiveRecord::BaseMethods
- WillPaginate::ActiveRecord::Pagination
- WillPaginate::ActiveRecord::RelationMethods
- WillPaginate::Collection
- WillPaginate::CollectionMethods
- WillPaginate::DataMapper
- WillPaginate::DataMapper::CollectionMethods
- WillPaginate::DataMapper::Pagination
- WillPaginate::Deprecation
- WillPaginate::Deprecation::Hash
- WillPaginate::I18n
- WillPaginate::InvalidPage
- WillPaginate::Merb
- WillPaginate::Merb::LinkRenderer
- WillPaginate::PageNumber
- WillPaginate::PerPage
- WillPaginate::PerPage::Inheritance
- WillPaginate::Railtie
- WillPaginate::Railtie::ControllerRescuePatch
- WillPaginate::Railtie::ShowExceptionsPatch
- WillPaginate::SequelMethods
- WillPaginate::Sinatra
- WillPaginate::Sinatra::Helpers
- WillPaginate::Sinatra::LinkRenderer
- WillPaginate::ViewHelpers
- WillPaginate::ViewHelpers::LinkRenderer
- WillPaginate::ViewHelpers::LinkRendererBase
- Array
- Object

No matching classes.

# WillPaginate::PageNumber

integer representing a page number

### Constants

BIGINT

  a value larger than this is not supported in SQL queries

### Public Class Methods

new(value, name) click to toggle source

    # File lib/will_paginate/page_number.rb, line 15
    def initialize(value, name)
      value = Integer(value)
      if 'offset' == name ? (value < 0 or value > BIGINT) : value < 1
        raise RangeError, "invalid #{name}: #{value.inspect}"
      end
      @name = name
      super(value)
    rescue ArgumentError, TypeError, RangeError => error
      error.extend InvalidPage
      raise error
    end

### Public Instance Methods

inspect() click to toggle source

    # File lib/will_paginate/page_number.rb, line 29
    def inspect
      "#{@name} #{to_i}"
    end

is_a?(klass) click to toggle source
Alias for: kind_of?
kind_of?(klass) click to toggle source

    # File lib/will_paginate/page_number.rb, line 37
    def kind_of?(klass)
      super || to_i.kind_of?(klass)
    end

Also aliased as: is_a?
to_offset(per_page) click to toggle source

    # File lib/will_paginate/page_number.rb, line 33
    def to_offset(per_page)
      PageNumber.new((to_i - 1) * per_page.to_i, 'offset')
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.