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)


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

lazy_attr_reader(:last?) {
  node = doc.at('ul.page-list .current')
  node ? node.next_element.nil? : true
}

#member_idInteger (readonly) Also known as: owner_id

Lazily returns member_id

Returns:

  • (Integer)


32
33
34
# File 'lib/pixiv/owned_illust_list.rb', line 32

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

#pageInteger (readonly)

Lazily returns page

Returns:

  • (Integer)


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

lazy_attr_reader(:page) {
  node = doc.at('ul.page-list .current')
  node ? node.inner_text.to_i : 1
}

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)


42
43
44
# File 'lib/pixiv/owned_illust_list.rb', line 42

def first?
  page == 1
end

#max_sizeInteger

Returns:

  • (Integer)


57
58
59
# File 'lib/pixiv/owned_illust_list.rb', line 57

def max_size
  ILLUSTS_PER_PAGE
end

#next_urlString

Returns:

  • (String)


47
48
49
# File 'lib/pixiv/owned_illust_list.rb', line 47

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

#prev_urlString

Returns:

  • (String)


52
53
54
# File 'lib/pixiv/owned_illust_list.rb', line 52

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

#urlString

Returns:

  • (String)


37
38
39
# File 'lib/pixiv/owned_illust_list.rb', line 37

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