added String() methods for various types
This commit is contained in:
parent
819221d01d
commit
e542fa0c97
25
types.go
25
types.go
@ -15,12 +15,22 @@ type ReadingList struct {
|
|||||||
Entries []ReadingListEntry `json:"entries"`
|
Entries []ReadingListEntry `json:"entries"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l ReadingList) String() string {
|
||||||
|
data, _ := json.MarshalIndent(l, "", "\t")
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
|
||||||
type ReadingListEntry struct {
|
type ReadingListEntry struct {
|
||||||
Novel NovelEntry `json:"novel"`
|
Novel NovelEntry `json:"novel"`
|
||||||
CurrentChapter ReadingListChapterEntry `json:"current_chapter"`
|
CurrentChapter ReadingListChapterEntry `json:"current_chapter"`
|
||||||
LatestChapter ReadingListChapterEntry `json:"latest_chapter"`
|
LatestChapter ReadingListChapterEntry `json:"latest_chapter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e ReadingListEntry) String() string {
|
||||||
|
data, _ := json.MarshalIndent(e, "", "\t")
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
|
||||||
func (e ReadingListEntry) NewChapterAvailable() bool {
|
func (e ReadingListEntry) NewChapterAvailable() bool {
|
||||||
return e.CurrentChapter.ID != e.LatestChapter.ID
|
return e.CurrentChapter.ID != e.LatestChapter.ID
|
||||||
}
|
}
|
||||||
@ -31,11 +41,21 @@ type ReadingListChapterEntry struct {
|
|||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e ReadingListChapterEntry) String() string {
|
||||||
|
data, _ := json.MarshalIndent(e, "", "\t")
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
|
||||||
type NovelEntry struct {
|
type NovelEntry struct {
|
||||||
NovelID NovelID `json:"id"`
|
NovelID NovelID `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e NovelEntry) String() string {
|
||||||
|
data, _ := json.MarshalIndent(e, "", "\t")
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
|
||||||
type Novel struct {
|
type Novel struct {
|
||||||
ID NovelID `json:"id"`
|
ID NovelID `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@ -48,6 +68,11 @@ type Novel struct {
|
|||||||
Tags []TagID `json:"tags"`
|
Tags []TagID `json:"tags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n Novel) String() string {
|
||||||
|
data, _ := json.MarshalIndent(n, "", "\t")
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
|
||||||
type NovelType string
|
type NovelType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Loading…
Reference in New Issue
Block a user