mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Add Manga object as a property of MangaDex::Chapter
This commit is contained in:
parent
905d02e911
commit
468f109776
@ -27,13 +27,14 @@ module Mangadex
|
|||||||
end
|
end
|
||||||
class Chapter
|
class Chapter
|
||||||
string_properties ["lang_code", "title", "volume", "chapter"]
|
string_properties ["lang_code", "title", "volume", "chapter"]
|
||||||
|
property manga : Manga
|
||||||
property time = Time.local
|
property time = Time.local
|
||||||
property id : String
|
property id : String
|
||||||
property language = ""
|
property language = ""
|
||||||
property pages = [] of {String, String} # filename, url
|
property pages = [] of {String, String} # filename, url
|
||||||
property groups = [] of {Int32, String} # group_id, group_name
|
property groups = [] of {Int32, String} # group_id, group_name
|
||||||
|
|
||||||
def initialize(@id, json_obj : JSON::Any, lang : Hash(String, String))
|
def initialize(@id, json_obj : JSON::Any, @manga, lang : Hash(String, String))
|
||||||
self.parse_json json_obj, lang
|
self.parse_json json_obj, lang
|
||||||
end
|
end
|
||||||
def to_info_json
|
def to_info_json
|
||||||
@ -44,6 +45,8 @@ module Mangadex
|
|||||||
json.field {{name}}, @{{name.id}}
|
json.field {{name}}, @{{name.id}}
|
||||||
{% end %}
|
{% end %}
|
||||||
json.field "time", @time.to_unix.to_s
|
json.field "time", @time.to_unix.to_s
|
||||||
|
json.field "manga_title", @manga.title
|
||||||
|
json.field "manga_id", @manga.id
|
||||||
json.field "groups" do
|
json.field "groups" do
|
||||||
json.object do
|
json.object do
|
||||||
@groups.each do |gid, gname|
|
@groups.each do |gid, gname|
|
||||||
@ -192,7 +195,7 @@ module Mangadex
|
|||||||
raise "" if obj["status"] != "OK"
|
raise "" if obj["status"] != "OK"
|
||||||
manga = Manga.new id, obj["manga"]
|
manga = Manga.new id, obj["manga"]
|
||||||
obj["chapter"].as_h.map do |k, v|
|
obj["chapter"].as_h.map do |k, v|
|
||||||
chapter = Chapter.new k, v, @lang
|
chapter = Chapter.new k, v, manga, @lang
|
||||||
manga.chapters << chapter
|
manga.chapters << chapter
|
||||||
end
|
end
|
||||||
return manga
|
return manga
|
||||||
|
Loading…
x
Reference in New Issue
Block a user