Class: Pixiv::Illust
Defined Under Namespace
Modules: WithClient
Instance Attribute Summary collapse
-
#anchors_in_caption ⇒ Array<Nokogiri::XML::NodeSet, nil>
readonly
Lazily returns anchors_in_caption.
-
#caption ⇒ String
readonly
Lazily returns caption.
-
#illust_id ⇒ Integer
(also: #id)
readonly
Lazily returns illust_id.
- #medium_image_url ⇒ String readonly
-
#member_id ⇒ Integer
(also: #author_id)
readonly
Lazily returns member_id.
-
#member_name ⇒ String
(also: #author_name)
readonly
Lazily returns member_name.
-
#num_pages ⇒ Integer?
readonly
Lazily returns num_pages.
-
#original_image_referer ⇒ String
(also: #original_image_referrer)
readonly
Lazily returns original_image_referer.
- #original_image_url ⇒ String readonly
-
#original_image_urls ⇒ Array<String>
readonly
Lazily returns original_image_urls.
-
#rated_count ⇒ Integer
readonly
Lazily returns rated_count.
-
#score ⇒ Integer
readonly
Lazily returns score.
-
#small_image_url ⇒ String
readonly
Lazily returns small_image_url.
-
#tag_names ⇒ Array<String>
readonly
Lazily returns tag_names.
-
#title ⇒ String
readonly
Lazily returns title.
-
#views_count ⇒ Integer
readonly
Lazily returns views_count.
Class Method Summary collapse
-
.url(illust_id) ⇒ String
Returns the URL for given
illust_id
.
Instance Method Summary collapse
Methods inherited from Page
#bind, #doc, #fetched?, #force, #initialize, lazy_new
Constructor Details
This class inherits a constructor from Pixiv::Page
Instance Attribute Details
#anchors_in_caption ⇒ Array<Nokogiri::XML::NodeSet, nil> (readonly)
Lazily returns anchors_in_caption
52 |
# File 'lib/pixiv/illust.rb', line 52 lazy_attr_reader(:anchors_in_caption) { doc.search('.work-info .caption a') } |
#caption ⇒ String (readonly)
Lazily returns caption
49 |
# File 'lib/pixiv/illust.rb', line 49 lazy_attr_reader(:caption) { at!('.work-info .caption').inner_text } |
#illust_id ⇒ Integer (readonly) Also known as: id
Lazily returns illust_id
29 |
# File 'lib/pixiv/illust.rb', line 29 lazy_attr_reader(:illust_id) { at!('#rpc_i_id')['title'].to_i } |
#medium_image_url ⇒ String (readonly)
18 |
# File 'lib/pixiv/illust.rb', line 18 lazy_attr_reader(:medium_image_url) { image_url_components.join('_m') } |
#member_id ⇒ Integer (readonly) Also known as:
Lazily returns member_id
31 |
# File 'lib/pixiv/illust.rb', line 31 lazy_attr_reader(:member_id) { at!('#rpc_u_id')['title'].to_i } |
#member_name ⇒ String (readonly) Also known as:
Lazily returns member_name
33 34 35 36 37 |
# File 'lib/pixiv/illust.rb', line 33 lazy_attr_reader(:member_name) { # Note: generally member_name can easily be found at +at('.profile_area a')['title']+ # but this is not the case on your own illust page; so this hack. at!('title').inner_text[%r!^「#{Regexp.escape(title)}」/「(.+)」の(?:イラスト|漫画) \[pixiv\]$!, 1] } |
#num_pages ⇒ Integer? (readonly)
Lazily returns num_pages
41 42 43 44 45 |
# File 'lib/pixiv/illust.rb', line 41 lazy_attr_reader(:num_pages) { node = doc.at('//ul[@class="meta"]/li[2]') n = node ? node.inner_text[/(\d+)P$/, 1] : nil n && n.to_i } |
#original_image_referer ⇒ String (readonly) Also known as: original_image_referrer
Lazily returns original_image_referer
27 |
# File 'lib/pixiv/illust.rb', line 27 lazy_attr_reader(:original_image_referer) { ROOT_URL + '/' + at!('//div[@class="works_display"]/a')['href'] } |
#original_image_url ⇒ String (readonly)
20 |
# File 'lib/pixiv/illust.rb', line 20 lazy_attr_reader(:original_image_url) { illust? && image_url_components.join('') } |
#original_image_urls ⇒ Array<String> (readonly)
Lazily returns original_image_urls
22 23 24 25 |
# File 'lib/pixiv/illust.rb', line 22 lazy_attr_reader(:original_image_urls) { illust? ? [original_image_url] : (0...num_pages).map {|n| image_url_components.join("_p#{n}") } } |
#rated_count ⇒ Integer (readonly)
Lazily returns rated_count
56 |
# File 'lib/pixiv/illust.rb', line 56 lazy_attr_reader(:rated_count) { at!('.rated-count').inner_text.to_i } |
#score ⇒ Integer (readonly)
Lazily returns score
58 |
# File 'lib/pixiv/illust.rb', line 58 lazy_attr_reader(:score) { at!('.score-count').inner_text.to_i } |
#small_image_url ⇒ String (readonly)
Lazily returns small_image_url
16 |
# File 'lib/pixiv/illust.rb', line 16 lazy_attr_reader(:small_image_url) { at!('meta[property="og:image"]')['content'] } |
#tag_names ⇒ Array<String> (readonly)
Lazily returns tag_names
47 |
# File 'lib/pixiv/illust.rb', line 47 lazy_attr_reader(:tag_names) { search!('ul.tags a.text').map {|n| n.inner_text } } |
#title ⇒ String (readonly)
Lazily returns title
39 |
# File 'lib/pixiv/illust.rb', line 39 lazy_attr_reader(:title) { at!('.work-info h1.title').inner_text } |
#views_count ⇒ Integer (readonly)
Lazily returns views_count
54 |
# File 'lib/pixiv/illust.rb', line 54 lazy_attr_reader(:views_count) { at!('.view-count').inner_text.to_i } |
Class Method Details
.url(illust_id) ⇒ String
Returns the URL for given illust_id
11 12 13 |
# File 'lib/pixiv/illust.rb', line 11 def self.url(illust_id) "#{ROOT_URL}/member_illust.php?mode=medium&illust_id=#{illust_id}" end |
Instance Method Details
#illust? ⇒ Boolean
68 |
# File 'lib/pixiv/illust.rb', line 68 def illust?; !manga? end |
#manga? ⇒ Boolean
70 |
# File 'lib/pixiv/illust.rb', line 70 def manga?; !!num_pages end |
#url ⇒ String
66 |
# File 'lib/pixiv/illust.rb', line 66 def url; self.class.url(illust_id) end |