class Mangadex::CoverArt
Public Class Methods
delete(id)
click to toggle source
# File lib/mangadex/cover_art.rb, line 76 def self.delete(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.delete( '/cover/%{id}' % {id: id}, ) end
edit(id, **args)
click to toggle source
# File lib/mangadex/cover_art.rb, line 62 def self.edit(id, **args) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.put( '/cover/%{id}' % {id: id}, Mangadex::Internal::Definition.validate(args, { volume: { accepts: String }, description: { accepts: String }, version: { accepts: Integer, required: true } }) ) end
Also aliased as: update
get(id, **args)
click to toggle source
# File lib/mangadex/cover_art.rb, line 50 def self.get(id, **args) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.get( '/cover/%{id}' % {id: id}, Mangadex::Internal::Definition.validate(args, { includes: { accepts: [String] }, }) ) end
Also aliased as: view
list(**args)
click to toggle source
# File lib/mangadex/cover_art.rb, line 16 def self.list(**args) Mangadex::Internal::Request.get( '/cover', Mangadex::Internal::Definition.validate(args, { limit: { accepts: Integer }, offset: { accepts: Integer }, manga: { accepts: [String] }, ids: { accepts: [String] }, uploaders: { accepts: [String] }, order: { accepts: Hash }, includes: { accepts: [String] }, }) ) end
upload(file, volume=nil, manga_id:)
click to toggle source
# File lib/mangadex/cover_art.rb, line 38 def self.upload(file, volume=nil, manga_id:) args = { file: file, volume: volume } Mangadex::Internal::Request.post( '/cover/%{manga_id}' % {manga_id: manga_id}, payload: Mangadex::Internal::Definition.validate(args, { file: { accepts: String, required: true }, volume: { accepts: %r{^(0|[1-9]\\d*)((\\.\\d+){1,2})?[a-z]?$} } # todo: double check regexp here }) ) end
Public Instance Methods
image_url(size: :small)
click to toggle source
# File lib/mangadex/cover_art.rb, line 90 def image_url(size: :small) return unless manga.present? extension = case size.to_sym when :original '' when :medium '.512.jpg' else # :small by default '.256.jpg' end "https://uploads.mangadex.org/covers/#{manga.id}/#{file_name}#{extension}" end