Class: PixivApi::Response::Pagination

Inherits:
PixivApi::Response show all
Defined in:
lib/pixiv_api/response/pagination.rb

Instance Attribute Summary collapse

Attributes inherited from PixivApi::Response

#attributes, #response

Class Method Summary collapse

Methods inherited from PixivApi::Response

#[], attr_reader, define_attribute_method, define_attributes_method, define_blob_method, define_time_method, #initialize

Constructor Details

This class inherits a constructor from PixivApi::Response

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



21
22
23
# File 'lib/pixiv_api/response/pagination.rb', line 21

def current
  @current
end

#nextObject (readonly)

Returns the value of attribute next.



21
22
23
# File 'lib/pixiv_api/response/pagination.rb', line 21

def next
  @next
end

#pagesObject (readonly)

Returns the value of attribute pages.



21
22
23
# File 'lib/pixiv_api/response/pagination.rb', line 21

def pages
  @pages
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



21
22
23
# File 'lib/pixiv_api/response/pagination.rb', line 21

def per_page
  @per_page
end

#previousObject (readonly)

Returns the value of attribute previous.



21
22
23
# File 'lib/pixiv_api/response/pagination.rb', line 21

def previous
  @previous
end

#totalObject (readonly)

Returns the value of attribute total.



21
22
23
# File 'lib/pixiv_api/response/pagination.rb', line 21

def total
  @total
end

Class Method Details

.define_pagination_url(*attrs) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pixiv_api/response/pagination.rb', line 8

def self.define_pagination_url(*attrs)
  attrs.each do |attr|
    define_method "#{attr}_url" do
      if self[attr]
        params = @request.params.merge('page' => self[attr])
        url = @request.url
        url.query = URI.encode_www_form(params)
        url
      end
    end
  end
end

.from_response(response, *attributes) ⇒ Object



4
5
6
# File 'lib/pixiv_api/response/pagination.rb', line 4

def self.from_response(response, *attributes)
  new(response, *attributes)
end