Class: Mangadex::CoverArt
Instance Attribute Summary
#attributes, #id, #related_type, #relationships, #type
Class Method Summary
collapse
Instance Method Summary
collapse
attributes_to_inspect, #eq?, #hash, #initialize, #inspect
Class Method Details
.edit(id, **args) ⇒ Object
Also known as:
update
.get(id, **args) ⇒ Object
Also known as:
view
.list(**args) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/mangadex/cover_art.rb', line 15
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:) ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/mangadex/cover_art.rb', line 37
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]?$} } })
)
end
|
Instance Method Details
#image_url(size: :small) ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/mangadex/cover_art.rb', line 89
def image_url(size: :small)
return unless manga.present?
extension = case size.to_sym
when :original
''
when :medium
'.512.jpg'
else '.256.jpg'
end
"https://uploads.mangadex.org/covers/#{manga.id}/#{file_name}#{extension}"
end
|