Class: PixivApi::Response::Work
- Inherits:
-
Identity
- Object
- PixivApi::Response
- Identity
- PixivApi::Response::Work
- Defined in:
- lib/pixiv_api/response/work.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#age_limit ⇒ Object
readonly
Returns the value of attribute age_limit.
-
#book_style ⇒ Object
readonly
Returns the value of attribute book_style.
-
#caption ⇒ Object
readonly
Returns the value of attribute caption.
-
#favorite_id ⇒ Object
readonly
Returns the value of attribute favorite_id.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_linked ⇒ Object
readonly
Returns the value of attribute is_linked.
-
#is_manga ⇒ Object
readonly
Returns the value of attribute is_manga.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#page_count ⇒ Object
readonly
Returns the value of attribute page_count.
-
#publicity ⇒ Object
readonly
Returns the value of attribute publicity.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Attributes inherited from PixivApi::Response
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Identity
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::Identity
Instance Attribute Details
#age_limit ⇒ Object (readonly)
Returns the value of attribute age_limit.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def age_limit @age_limit end |
#book_style ⇒ Object (readonly)
Returns the value of attribute book_style.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def book_style @book_style end |
#caption ⇒ Object (readonly)
Returns the value of attribute caption.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def caption @caption end |
#favorite_id ⇒ Object (readonly)
Returns the value of attribute favorite_id.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def favorite_id @favorite_id end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def height @height end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def id @id end |
#is_linked ⇒ Object (readonly)
Returns the value of attribute is_linked.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def is_linked @is_linked end |
#is_manga ⇒ Object (readonly)
Returns the value of attribute is_manga.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def is_manga @is_manga end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def @metadata end |
#page_count ⇒ Object (readonly)
Returns the value of attribute page_count.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def page_count @page_count end |
#publicity ⇒ Object (readonly)
Returns the value of attribute publicity.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def publicity @publicity end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def stats @stats end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def title @title end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def tools @tools end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def type @type end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
21 22 23 |
# File 'lib/pixiv_api/response/work.rb', line 21 def width @width end |
Class Method Details
.from_response(response, *args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pixiv_api/response/work.rb', line 4 def self.from_response(response, *args) attributes = args. base = case attributes['type'] when 'illustration' Illustration when 'manga' Manga when 'ugoira' Ugoira else raise NotImplementedError, 'unknown type given.' end base.new(response, attributes) end |
Instance Method Details
#pages ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pixiv_api/response/work.rb', line 32 def pages @attributes['metadata']['pages'].map do |base, memo| base['image_urls'].each_with_object({}) do |(key, value), memo| memo[key] = blob_image_url(value) end end rescue # XXX: workの種類によってはエラーが起こる? [] end |