Class: Net::Flickr::List

### Home Classes Methods

### In Files

- lib/net/flickr/list.rb

### Parent

Object

### Methods

- ::new
- #[]
- #each
- #first_page?
- #last_page?
- #next
- #page=
- #per_page=
- #prev
- #previous

### Included Modules

- Enumerable

### Class/Module Index

Quicksearch

- Net
- Net::Flickr
- Net::Flickr::APIError
- Net::Flickr::Auth
- Net::Flickr::InvalidResponse
- Net::Flickr::List
- Net::Flickr::ListError
- Net::Flickr::People
- Net::Flickr::Person
- Net::Flickr::Photo
- Net::Flickr::PhotoList
- Net::Flickr::Photos
- Net::Flickr::Tag

No matching classes.

# Net::Flickr::List

Base class for paginated lists.

Don't instantiate this class yourself. It's a base class extended by `PhotoList` and others.

### Attributes

page[R]
pages[R]
per_page[R]
total[R]

### Public Class Methods

new(flickr, load_method, load_args) click to toggle source

    # File lib/net/flickr/list.rb, line 40
    def initialize(flickr, load_method, load_args)
      @flickr      = flickr
      @load_method = load_method
      @load_args   = load_args

      update_list
    end

### Public Instance Methods

[](index) click to toggle source

    # File lib/net/flickr/list.rb, line 52
    def [](index)
      return @items[index]
    end

each() click to toggle source

    # File lib/net/flickr/list.rb, line 56
    def each
      @items.each {|item| yield item }
    end

first_page?() click to toggle source

Returns `true` if the current page is the first page of the list, `false` otherwise.

    # File lib/net/flickr/list.rb, line 62
    def first_page?
      return @page == 1
    end

last_page?() click to toggle source

Returns `true` if the current page is the last page of the list, `false` otherwise.

    # File lib/net/flickr/list.rb, line 68
    def last_page?
      return @page == @pages
    end

next() click to toggle source

Loads the next page in the list.

    # File lib/net/flickr/list.rb, line 73
    def next
      if last_page?
        raise ListError, 'Already on the last page of the list'
      end

      @load_args['page'] = @page + 1
      update_list
    end

page=(page) click to toggle source

Loads the specified page in the list.

    # File lib/net/flickr/list.rb, line 83
    def page=(page)
      if page < 1 || page > @pages
        raise ArgumentError, 'Page number out of bounds'
      end

      @load_args['page'] = page
      update_list
    end

per_page=(per_page) click to toggle source

Sets the number of items loaded per page. Must be between 1 and 500 inclusive.

    # File lib/net/flickr/list.rb, line 94
    def per_page=(per_page)
      if per_page < 1 || per_page > 500
        raise ArgumentError, 'per_page must be between 1 and 500 inclusive'
      end

      @per_page = per_page
      @load_args['per_page'] = @per_page
    end

prev() click to toggle source
Alias for: previous
previous() click to toggle source

Loads the previous page in the list.

    # File lib/net/flickr/list.rb, line 104
    def previous
      if first_page?
        raise ListError, 'Already on the first page of the list'
      end

      @load_args['page'] = @page - 1
      update_list
    end

Also aliased as: prev

[Validate]

Generated with the Darkfish Rdoc Generator 2.