class PixivApi::Response::Work

Attributes

age_limit[R]
book_style[R]
caption[R]
favorite_id[R]
height[R]
id[R]
is_linked[R]
is_manga[R]
metadata[R]
page_count[R]
publicity[R]
stats[R]
title[R]
tools[R]
type[R]
width[R]

Public Class Methods

from_response(response, *args) click to toggle source
# File lib/pixiv_api/response/work.rb, line 4
def self.from_response(response, *args)
  attributes = args.extract_options!

  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

Public Instance Methods

pages() click to toggle source
# 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