Class: Mangadex::CoverArt
Instance Attribute Summary
#attributes, #id, #relationships, #type
Class Method Summary
collapse
Instance Method Summary
collapse
attributes_to_inspect, #eq?, #hash, #initialize, #inspect
Class Method Details
.delete(id) ⇒ Object
71
72
73
74
75
|
# File 'lib/mangadex/cover_art.rb', line 71
def self.delete(id)
Mangadex::Internal::Request.delete(
'/cover/%{id}' % {id: id},
)
end
|
.edit(id, **args) ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/mangadex/cover_art.rb', line 59
def self.edit(id, **args)
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
|
.get(id, **args) ⇒ Object
.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/mangadex/cover_art.rb', line 78
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
|