jikan.rb 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+ require 'jikan/models/entity'
2
+
3
+ module Jikan
4
+ class CharacterStaff < BaseEntity
5
+
6
+ def mal_id
7
+ raw['mal_id']
8
+ end
9
+
10
+ def url
11
+ raw['url']
12
+ end
13
+
14
+ def image_url
15
+ raw['image_url']
16
+ end
17
+
18
+ def role
19
+ raw['role']
20
+ end
21
+
22
+ def voice_actors
23
+ raw['voice_actors'].map do |va|
24
+ VoiceActor.new(va)
25
+ end
26
+ end
27
+
28
+ class VoiceActor < BaseEntity
29
+
30
+ def mal_id
31
+ raw['mal_id']
32
+ end
33
+
34
+ def name
35
+ raw['name']
36
+ end
37
+
38
+ def url
39
+ raw['url']
40
+ end
41
+
42
+ def image_url
43
+ raw['image_url']
44
+ end
45
+
46
+ def language
47
+ raw['language']
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,55 @@
1
+ module Jikan
2
+ class Character < BaseEntity
3
+ def mal_id
4
+ raw['mal_id']
5
+ end
6
+
7
+ def url
8
+ raw['url']
9
+ end
10
+
11
+ def name
12
+ raw['name']
13
+ end
14
+
15
+ def image_url
16
+ raw['image_url']
17
+ end
18
+
19
+ def name_kanji
20
+ raw['name_kanji']
21
+ end
22
+
23
+ def nicknames
24
+ raw['nicknames']
25
+ end
26
+
27
+ def about
28
+ raw['about']
29
+ end
30
+
31
+ def member_fav
32
+ raw['member_favorites']
33
+ end
34
+
35
+ def animeography
36
+ raw['animeography'].map do |a|
37
+ Jikan::BasicAnime.new(a)
38
+ end
39
+ end
40
+
41
+ def mangaography
42
+ raw['mangaography'].map do |m|
43
+ Jikan::BasicManga.new(m)
44
+ end
45
+ end
46
+
47
+ def va
48
+ raw['voice_actors'].map do |va|
49
+ Jikan::VoiceActor.new(va)
50
+ end
51
+ end
52
+ end
53
+
54
+ class BasicCharacter < Entityography; end
55
+ end
@@ -0,0 +1,80 @@
1
+ module Jikan
2
+ class Club < BaseEntity
3
+ def mal_id
4
+ raw['mal_id']
5
+ end
6
+
7
+ def url
8
+ raw['url']
9
+ end
10
+
11
+ def image_url
12
+ raw['image_url']
13
+ end
14
+
15
+ def title
16
+ raw['title']
17
+ end
18
+
19
+ def members_count
20
+ raw['members_count']
21
+ end
22
+
23
+ def pictures_count
24
+ raw['pictures_count']
25
+ end
26
+
27
+ def category
28
+ raw['category']
29
+ end
30
+
31
+ def created
32
+ raw['created']
33
+ end
34
+
35
+ def type
36
+ raw['type']
37
+ end
38
+
39
+ def staff
40
+ raw['staff'].map do |s|
41
+ ClubEntity.new(s)
42
+ end
43
+ end
44
+
45
+ def anime_relations
46
+ raw['anime_relations'].map do |r|
47
+ ClubEntity.new(r)
48
+ end
49
+ end
50
+
51
+ def manga_relations
52
+ raw['manga_relations'].map do |r|
53
+ ClubEntity.new(r)
54
+ end
55
+ end
56
+
57
+ def character_relations
58
+ raw['character_relations'].map do |r|
59
+ ClubEntity.new(r)
60
+ end
61
+ end
62
+ end
63
+
64
+ class ClubEntity < Entityography; end
65
+
66
+ class ClubMember < BaseEntity
67
+
68
+ def username
69
+ raw['username']
70
+ end
71
+
72
+ def url
73
+ raw['url']
74
+ end
75
+
76
+ def image_url
77
+ raw['url']
78
+ end
79
+ end
80
+ end
@@ -1,90 +1,116 @@
1
- module Jikan
2
- class BaseEntity
3
-
4
- attr_reader :raw
5
-
6
- def initialize(json)
7
- @raw = json
8
- end
9
-
10
- end
11
-
12
- class MediaEntity < BaseEntity
13
-
14
- def favorites
15
- raw['favorites']
16
- end
17
-
18
- def genre
19
- raw['genre']
20
- end
21
-
22
- def id
23
- raw['id'] || raw['mal_id']
24
- end
25
-
26
- def image
27
- raw['image'] || raw['image_url']
28
- end
29
-
30
- def members
31
- raw['members']
32
- end
33
-
34
- def popularity
35
- raw['popularity']
36
- end
37
-
38
- def ranked
39
- raw['ranked']
40
- end
41
-
42
- def rating
43
- raw['rating']
44
- end
45
-
46
- def status
47
- raw['status']
48
- end
49
-
50
- def score
51
- raw['score']
52
- end
53
-
54
- def source
55
- raw['source']
56
- end
57
-
58
- def synonyms
59
- raw['synonyms']
60
- end
61
-
62
- def synopsis
63
- raw['synopsis'] || raw['description']
64
- end
65
-
66
- def link
67
- raw['link_canonical'] || raw['url']
68
- end
69
-
70
- def title
71
- raw['title']
72
- end
73
-
74
- def title_en
75
- raw['title_english']
76
- end
77
-
78
- def title_jp
79
- raw['japanese']
80
- end
81
-
82
- def title_synonyms
83
- raw['title_synonyms']
84
- end
85
-
86
- def type
87
- raw['type']
88
- end
89
- end
1
+ module Jikan
2
+ class BaseEntity
3
+
4
+ attr_reader :raw
5
+
6
+ def initialize(json)
7
+ @raw = json
8
+ end
9
+
10
+ end
11
+
12
+ class MediaEntity < BaseEntity
13
+
14
+ def favorites
15
+ raw['favorites']
16
+ end
17
+
18
+ def genre
19
+ raw['genre'] || raw['genres']
20
+ end
21
+
22
+ def id
23
+ raw['id'] || raw['mal_id']
24
+ end
25
+
26
+ def image
27
+ raw['image'] || raw['image_url']
28
+ end
29
+
30
+ def members
31
+ raw['members']
32
+ end
33
+
34
+ def popularity
35
+ raw['popularity']
36
+ end
37
+
38
+ def ranked
39
+ raw['ranked']
40
+ end
41
+
42
+ def rating
43
+ raw['rating']
44
+ end
45
+
46
+ def status
47
+ raw['status']
48
+ end
49
+
50
+ def score
51
+ raw['score']
52
+ end
53
+
54
+ def source
55
+ raw['source']
56
+ end
57
+
58
+ def synonyms
59
+ raw['synonyms']
60
+ end
61
+
62
+ def synopsis
63
+ raw['synopsis'] || raw['description']
64
+ end
65
+
66
+ def link
67
+ raw['link_canonical'] || raw['url']
68
+ end
69
+
70
+ def title
71
+ raw['title']
72
+ end
73
+
74
+ def title_en
75
+ raw['title_english']
76
+ end
77
+
78
+ def title_jp
79
+ raw['japanese']
80
+ end
81
+
82
+ def title_synonyms
83
+ raw['title_synonyms']
84
+ end
85
+
86
+ def type
87
+ raw['type']
88
+ end
89
+ end
90
+
91
+ class Entityography < BaseEntity
92
+ def mal_id
93
+ raw['mal_id']
94
+ end
95
+
96
+ def name
97
+ raw['name']
98
+ end
99
+
100
+ def url
101
+ raw['url']
102
+ end
103
+
104
+ def image_url
105
+ raw['image_url']
106
+ end
107
+
108
+ def role
109
+ raw['role']
110
+ end
111
+
112
+ def type
113
+ raw['type']
114
+ end
115
+ end
90
116
  end
@@ -1,27 +1,29 @@
1
- module Jikan
2
- class Manga < MediaEntity
3
-
4
- def author
5
- raw['author']
6
- end
7
-
8
- def chapters
9
- raw['chapters']
10
- end
11
-
12
- def published
13
- raw['published']
14
- end
15
-
16
- def volumes
17
- raw['volumes']
18
- end
19
-
20
- end
21
-
22
- class MangaResult < Manga
23
- def details(flag=nil)
24
- Jikan::manga id, flag
25
- end
26
- end
27
- end
1
+ module Jikan
2
+ class Manga < MediaEntity
3
+
4
+ def author
5
+ raw['author']
6
+ end
7
+
8
+ def chapters
9
+ raw['chapters']
10
+ end
11
+
12
+ def published
13
+ raw['published']
14
+ end
15
+
16
+ def volumes
17
+ raw['volumes']
18
+ end
19
+
20
+ end
21
+
22
+ class MangaResult < Manga
23
+ def details(flag=nil)
24
+ Jikan::manga id, flag
25
+ end
26
+ end
27
+
28
+ class BasicManga < Entityography; end
29
+ end