Class: Pixiv::OwnedIllustList Abstract

Inherits:
IllustList show all
Defined in:
lib/pixiv/owned_illust_list.rb

Overview

This class is abstract.

Illust list owned by a member

Implements common methods for bookmark.php and member_illust.php.

Direct Known Subclasses

BookmarkList, WorkList

Defined Under Namespace

Modules: WithClient

Constant Summary collapse

ILLUSTS_PER_PAGE =

include ::Pixiv::OwnedIllustList::WithClient

20

Instance Attribute Summary collapse

Attributes inherited from IllustList

#total_count

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IllustList

#doc, #illust_hashes, #page_class

Methods included from PageCollection

#next_attrs, #page_class, #page_hashes, #prev_attrs, #size

Methods inherited from Page

#bind, #doc, #fetched?, #force, #initialize, lazy_new

Constructor Details

This class inherits a constructor from Pixiv::Page

Instance Attribute Details

#last?Boolean (readonly)

Lazily returns last?

Returns:

  • (Boolean)


26
27
28
# File 'lib/pixiv/owned_illust_list.rb', line 26

lazy_attr_reader(:last?) {
  at!('ul.page-list .current').next_element.nil?
}

#member_idInteger (readonly) Also known as: owner_id

Lazily returns member_id

Returns:

  • (Integer)


30
31
32
# File 'lib/pixiv/owned_illust_list.rb', line 30

lazy_attr_reader(:member_id) {
  doc.body[/pixiv\.context\.userId = '(\d+)'/, 1].to_i
}

#pageInteger (readonly)

Lazily returns page

Returns:

  • (Integer)


22
23
24
# File 'lib/pixiv/owned_illust_list.rb', line 22

lazy_attr_reader(:page) {
  at!('ul.page-list .current').inner_text.to_i
}

Class Method Details

.url(member_id, page = 1) ⇒ String

Returns the URL for given member_id and page

Parameters:

  • member_id (Integer)
  • page (Integer) (defaults to: 1)

Returns:

  • (String)

Raises:

  • (NotImplementError)


17
18
19
# File 'lib/pixiv/owned_illust_list.rb', line 17

def self.url(member_id, page = 1)
  raise NotImplementError
end

Instance Method Details

#first?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/pixiv/owned_illust_list.rb', line 40

def first?
  page == 1
end

#max_sizeInteger

Returns:

  • (Integer)


55
56
57
# File 'lib/pixiv/owned_illust_list.rb', line 55

def max_size
  ILLUSTS_PER_PAGE
end

#next_urlString

Returns:

  • (String)


45
46
47
# File 'lib/pixiv/owned_illust_list.rb', line 45

def next_url
  last? ? nil : self.class.url(member_id, page + 1)
end

#prev_urlString

Returns:

  • (String)


50
51
52
# File 'lib/pixiv/owned_illust_list.rb', line 50

def prev_url
  first? ? nil : self.class.url(member_id, page - 1)
end

#urlString

Returns:

  • (String)


35
36
37
# File 'lib/pixiv/owned_illust_list.rb', line 35

def url
  self.class.url(member_id, page)
end