Class: Mangadex::Manga
- Inherits:
-
MangadexObject
- Object
- MangadexObject
- Mangadex::Manga
- Defined in:
- lib/mangadex/manga.rb
Instance Attribute Summary
Attributes included from Internal::WithAttributes
#attributes, #id, #related_type, #relationships, #type
Class Method Summary collapse
- .all_reading_status(status) ⇒ Object
- .attributes_to_inspect ⇒ Object
- .create(**args) ⇒ Object
- .delete(id) ⇒ Object
- .feed(id, **args) ⇒ Object
- .follow(id) ⇒ Object
- .list(**args) ⇒ Object
- .random(**args) ⇒ Object
- .reading_status(id) ⇒ Object
- .tag_list ⇒ Object
- .unfollow(id) ⇒ Object
- .update(id, **args) ⇒ Object (also: edit)
- .update_reading_status(id, status) ⇒ Object
- .view(id, **args) ⇒ Object (also: get)
- .volumes_and_chapters(id, **args) ⇒ Object (also: aggregate)
Instance Method Summary collapse
Methods inherited from MangadexObject
#eq?, #hash, #initialize, #inspect
Constructor Details
This class inherits a constructor from Mangadex::MangadexObject
Class Method Details
.all_reading_status(status) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/mangadex/manga.rb', line 127 def self.all_reading_status(status) args = { status: status } Mangadex::Internal::Request.get( '/manga/status', Mangadex::Internal::Definition.validate(args, { status: { accepts: %w(reading on_hold dropped plan_to_read re_reading completed), converts: :to_s, }, }) ) end |
.attributes_to_inspect ⇒ Object
186 187 188 |
# File 'lib/mangadex/manga.rb', line 186 def self.attributes_to_inspect [:id, :type, :title, :content_rating, :original_language, :year] end |
.create(**args) ⇒ Object
182 183 184 |
# File 'lib/mangadex/manga.rb', line 182 def self.create(**args) Mangadex::Internal::Request.post('/manga', payload: args) end |
.delete(id) ⇒ Object
174 175 176 177 178 179 180 |
# File 'lib/mangadex/manga.rb', line 174 def self.delete(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.delete( '/manga/%{id}' % {id: id}, ) end |
.feed(id, **args) ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/mangadex/manga.rb', line 99 def self.feed(id, **args) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.get( '/manga/%{id}/feed' % {id: id}, Mangadex::Internal::Definition.chapter_list(args), content_rating: true, ) end |
.follow(id) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/mangadex/manga.rb', line 90 def self.follow(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.post( '/manga/%{id}/follow' % {id: id}, ) end |
.list(**args) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mangadex/manga.rb', line 25 def self.list(**args) to_a = Mangadex::Internal::Definition.converts(:to_a) Mangadex::Internal::Request.get( '/manga', Mangadex::Internal::Definition.validate(args, { limit: { accepts: Integer }, offset: { accepts: Integer }, title: { accepts: String }, authors: { accepts: [String] }, artists: { accepts: [String] }, year: { accepts: Integer }, included_tags: { accepts: [String] }, included_tags_mode: { accepts: %w(OR AND), converts: to_a }, excluded_tags: { accepts: [String] }, excluded_tags_mode: { accepts: %w(OR AND), converts: to_a }, status: { accepts: %w(ongoing completed hiatus cancelled), converts: to_a }, original_language: { accepts: [String] }, excluded_original_language: { accepts: [String] }, available_translated_language: { accepts: [String] }, publication_demographic: { accepts: %w(shounen shoujo josei seinen none), converts: to_a }, ids: { accepts: Array }, content_rating: { accepts: %w(safe suggestive erotica pornographic), converts: to_a }, created_at_since: { accepts: %r{^\d{4}-[0-1]\d-([0-2]\d|3[0-1])T([0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$} }, updated_at_since: { accepts: %r{^\d{4}-[0-1]\d-([0-2]\d|3[0-1])T([0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$} }, order: { accepts: Hash }, includes: { accepts: Array, converts: to_a }, }), content_rating: true, ) end |
.random(**args) ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/mangadex/manga.rb', line 110 def self.random(**args) Mangadex::Internal::Request.get( '/manga/random', Mangadex::Internal::Definition.validate(args, { includes: { accepts: Array }, }) ) end |
.reading_status(id) ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/mangadex/manga.rb', line 142 def self.reading_status(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.get( '/manga/%{id}/status' % {id: id}, ) end |
.tag_list ⇒ Object
120 121 122 123 124 |
# File 'lib/mangadex/manga.rb', line 120 def self.tag_list Mangadex::Internal::Request.get( '/manga/tag' ) end |
.unfollow(id) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/mangadex/manga.rb', line 81 def self.unfollow(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.delete( '/manga/%{id}/follow' % {id: id}, ) end |
.update(id, **args) ⇒ Object Also known as: edit
167 168 169 170 171 |
# File 'lib/mangadex/manga.rb', line 167 def self.update(id, **args) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.put('/manga/%{id}' % {id: id}, payload: args) end |
.update_reading_status(id, status) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/mangadex/manga.rb', line 151 def self.update_reading_status(id, status) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.post( '/manga/%{id}/status' % {id: id}, payload: Mangadex::Internal::Definition.validate({status: status}, { status: { accepts: %w(reading on_hold dropped plan_to_read re_reading completed), required: true, }, }) ) end |
.view(id, **args) ⇒ Object Also known as: get
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/mangadex/manga.rb', line 69 def self.view(id, **args) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.get( '/manga/%{id}' % {id: id}, Mangadex::Internal::Definition.validate(args, { includes: { accepts: Array }, }) ) end |
.volumes_and_chapters(id, **args) ⇒ Object Also known as: aggregate
58 59 60 61 62 63 64 65 66 |
# File 'lib/mangadex/manga.rb', line 58 def self.volumes_and_chapters(id, **args) Mangadex::Internal::Request.get( '/manga/%{id}/aggregate' % {id: id}, Mangadex::Internal::Definition.validate(args, { translated_language: { accepts: Array }, groups: { accepts: Array }, }), ) end |
Instance Method Details
#content_rating ⇒ Object
197 198 199 200 201 |
# File 'lib/mangadex/manga.rb', line 197 def return unless attributes&..present? ContentRating.new(attributes.) end |