kodi_client 0.4.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/kodi_client.gemspec +5 -2
  4. data/lib/kodi_client/Chainable.rb +3 -1
  5. data/lib/kodi_client/global_types/addon_types.rb +60 -48
  6. data/lib/kodi_client/global_types/application_types.rb +19 -16
  7. data/lib/kodi_client/global_types/audio_types.rb +41 -30
  8. data/lib/kodi_client/global_types/favourites_types.rb +18 -17
  9. data/lib/kodi_client/global_types/global_types.rb +29 -27
  10. data/lib/kodi_client/global_types/gui_types.rb +21 -15
  11. data/lib/kodi_client/global_types/input_types.rb +1 -1
  12. data/lib/kodi_client/global_types/item_types.rb +6 -2
  13. data/lib/kodi_client/global_types/list_types.rb +256 -89
  14. data/lib/kodi_client/global_types/media_types.rb +16 -11
  15. data/lib/kodi_client/global_types/player_type.rb +126 -107
  16. data/lib/kodi_client/global_types/profiles_types.rb +80 -0
  17. data/lib/kodi_client/global_types/pvr_type.rb +2 -0
  18. data/lib/kodi_client/global_types/system_types.rb +36 -0
  19. data/lib/kodi_client/global_types/video_types.rb +66 -41
  20. data/lib/kodi_client/kodi_module.rb +1 -0
  21. data/lib/kodi_client/method/addons.rb +2 -3
  22. data/lib/kodi_client/method/application.rb +1 -1
  23. data/lib/kodi_client/method/favourites.rb +1 -1
  24. data/lib/kodi_client/method/gui.rb +2 -2
  25. data/lib/kodi_client/method/player.rb +6 -6
  26. data/lib/kodi_client/method/profiles.rb +48 -0
  27. data/lib/kodi_client/method/system.rb +58 -0
  28. data/lib/kodi_client/util/comparable.rb +4 -1
  29. data/lib/kodi_client/util/creatable.rb +52 -0
  30. data/lib/kodi_client.rb +10 -8
  31. metadata +10 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 860eb2c3848cb508f5faaad0bf3716e330d1cb1113ebdfd6d847ccd33302d360
4
- data.tar.gz: d51f977964b4a89698985c7cfb5f78f83b83a1c00502d436eee6b84550177f28
3
+ metadata.gz: 0dd073d0e999df44e921b07f3aab1c148ee3647a584e2de13a2c070a151f7a2b
4
+ data.tar.gz: 00ac80c0f82b4bfcb0031e8cc2abf6e4c894ccff58515fcdfd08fbe1c3b7fb63
5
5
  SHA512:
6
- metadata.gz: 55f60b1ad247d88fcb77ae527a3b47a43521853d8f3d06f6fbe29db07ec465fb91c29a6146ec20414dadb0c00191172e974fae29291d63d1cbabd50e2105666d
7
- data.tar.gz: dad48a6e2c40302af39190e88a531d268f7b20f08cdac4322f73406c78d5b1a02df351faa260afab5094edb1aa1f301cce4be6c2c2c2c707c32e7c59c15cbf5a
6
+ metadata.gz: b1a718355773fd1a1e12127f334f74a9bc1d9382ec47e9143a2dc776e1bb056157f4ac5ca0ec1232b14c27c8cc55bacacae1b37e0b831213af7472c2aeef16ec
7
+ data.tar.gz: e6dccd2f74a7c2f7a4790635b21f01730c88a69bfe47c6b8905b500dade3b650689506640a2428c00824ca03097658906563a7f88806aad094a3dc64d7edcf0c
data/README.md CHANGED
@@ -9,6 +9,8 @@ Currently implemented are the following Methods:
9
9
  * GUI
10
10
  * Input
11
11
  * Player
12
+ * Profile
13
+ * System
12
14
 
13
15
  ## Installation
14
16
  from [rubygems](https://rubygems.org/gems/kodi_client) using
data/kodi_client.gemspec CHANGED
@@ -2,12 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'kodi_client'
5
- spec.version = '0.4.5'
5
+ spec.version = '0.5.7'
6
6
  spec.authors = ['Christian Feier']
7
7
  spec.email = ['christian.feier@gmail.com']
8
8
 
9
9
  spec.summary = 'A work-in-progress client for Kodi JSON API v2.'
10
- spec.description = 'A client for the Kodi JSON API v12, currently implemented methods are addons, application, Favourites, gui, Input and player (more will be added with the time). For more information how to use it and how to activate Remote Control in Kodi, please check the github page https://github.com/cfe86/RubyKodiClient'
10
+ spec.description = 'A client for the Kodi JSON API v12, currently implemented methods are addons, application, '\
11
+ 'favourites, gui, input, player, profile and system (more will be added with the time). '\
12
+ 'For more information how to use it and how to activate Remote Control in Kodi, '\
13
+ 'please check the github page https://github.com/cfe86/RubyKodiClient'
11
14
  spec.homepage = 'https://github.com/cfe86/RubyKodiClient'
12
15
  spec.license = 'MIT'
13
16
  spec.required_ruby_version = '>= 2.5.0'
@@ -24,7 +24,7 @@ module KodiClient
24
24
  client = def_client
25
25
  options = def_options
26
26
  set_command.call(options)
27
- client.apply_options(options)
27
+ client.apply_options_to_methods(options)
28
28
  client
29
29
  end
30
30
 
@@ -43,5 +43,7 @@ module KodiClient
43
43
  end
44
44
  @options
45
45
  end
46
+
47
+ private :def_client, :def_options, :merge_options
46
48
  end
47
49
  end
@@ -3,6 +3,7 @@
3
3
  require 'kodi_client/global_types/item_types'
4
4
  require 'kodi_client/util/comparable'
5
5
  require 'kodi_client/util/iterable'
6
+ require 'kodi_client/util/creatable'
6
7
 
7
8
  module KodiClient
8
9
  module Types
@@ -10,7 +11,7 @@ module KodiClient
10
11
 
11
12
  # Addon Types https://kodi.wiki/view/JSON-RPC_API/v12#Addon.Types
12
13
  module AddonTypes
13
- include Iterable
14
+ extend Iterable
14
15
 
15
16
  UNKNOWN = 'unknown'
16
17
  KODI_ADSP = 'kodi.adsp'
@@ -51,7 +52,8 @@ module KodiClient
51
52
 
52
53
  # Addon.Content https://kodi.wiki/view/JSON-RPC_API/v12#Addon.Content
53
54
  module AddonContent
54
- include Iterable
55
+ extend Iterable
56
+
55
57
  UNKNOWN = 'unknown'
56
58
  AUDIO = 'audio'
57
59
  EXECUTABLE = 'executable'
@@ -83,33 +85,27 @@ module KodiClient
83
85
  # represents addon dependency
84
86
  class AddonDependency
85
87
  include Comparable
88
+ extend Creatable
86
89
 
87
- attr_reader :addonid, :optional, :version
90
+ attr_reader :addon_id, :optional, :version
88
91
 
89
- def initialize(hash)
90
- @addonid = hash['addonid']
91
- @optional = hash['optional']
92
- @version = hash['version']
93
- end
94
-
95
- def ==(other)
96
- compare(self, other)
92
+ def initialize(addon_id, optional, version)
93
+ @addon_id = addon_id
94
+ @optional = optional
95
+ @version = version
97
96
  end
98
97
  end
99
98
 
100
99
  # represents addon extra info
101
100
  class AddonExtraInfo
102
101
  include Comparable
102
+ extend Creatable
103
103
 
104
104
  attr_reader :key, :value
105
105
 
106
- def initialize(hash)
107
- @key = hash['key']
108
- @value = hash['value']
109
- end
110
-
111
- def ==(other)
112
- compare(self, other)
106
+ def initialize(key, value)
107
+ @key = key
108
+ @value = value
113
109
  end
114
110
  end
115
111
 
@@ -117,33 +113,43 @@ module KodiClient
117
113
  class AddonDetails
118
114
  include Comparable
119
115
  include Items::ItemDetailsBase
116
+ extend Creatable
120
117
 
121
118
  attr_reader :addon_id, :author, :broken, :dependencies, :description, :disclaimer, :enabled, :extra_info,
122
119
  :fan_art, :installed, :name, :path, :rating, :summary, :thumbnail, :type, :version
123
120
 
124
- def initialize(hash)
125
- @addon_id = hash['addonid']
126
- @author = hash['author']
127
- @broken = hash['broken']
128
- @dependencies = hash['dependencies'].nil? ? nil : hash['dependencies'].map { |it| AddonDependency.new(it) }
129
- @description = hash['description']
130
- @disclaimer = hash['disclaimer']
131
- @enabled = hash['enabled']
132
- @extra_info = hash['extrainfo'].nil? ? nil : hash['extrainfo'].map { |it| AddonExtraInfo.new(it) }
133
- @fan_art = hash['fanart']
134
- @installed = hash['installed']
135
- @name = hash['name']
136
- @path = hash['path']
137
- @rating = hash['rating']
138
- @summary = hash['summary']
139
- @thumbnail = hash['thumbnail']
140
- @type = hash['type']
141
- @version = hash['version']
142
- item_details_base(hash)
121
+ def self.create(hash)
122
+ return nil if hash.nil?
123
+
124
+ dependencies = AddonDependency.create_list(hash['dependencies'])
125
+ extra_info = AddonExtraInfo.create_list(hash['extrainfo'])
126
+
127
+ new(hash['addonid'], hash['author'], hash['broken'], dependencies, hash['description'], hash['disclaimer'],
128
+ hash['enabled'], extra_info, hash['fanart'], hash['installed'], hash['name'], hash['path'],
129
+ hash['rating'], hash['summary'], hash['thumbnail'], hash['type'], hash['version'],
130
+ *hash_to_arr(hash, ['label']))
143
131
  end
144
132
 
145
- def ==(other)
146
- compare(self, other)
133
+ def initialize(addon_id, author, broken, dependencies, description, disclaimer, enabled, extra_info,
134
+ fan_art, installed, name, path, rating, summary, thumbnail, type, version, label)
135
+ @addon_id = addon_id
136
+ @author = author
137
+ @broken = broken
138
+ @dependencies = dependencies
139
+ @description = description
140
+ @disclaimer = disclaimer
141
+ @enabled = enabled
142
+ @extra_info = extra_info
143
+ @fan_art = fan_art
144
+ @installed = installed
145
+ @name = name
146
+ @path = path
147
+ @rating = rating
148
+ @summary = summary
149
+ @thumbnail = thumbnail
150
+ @type = type
151
+ @version = version
152
+ item_details_base(label)
147
153
  end
148
154
  end
149
155
 
@@ -153,13 +159,17 @@ module KodiClient
153
159
 
154
160
  attr_reader :addons, :limits
155
161
 
156
- def initialize(hash)
157
- @addons = hash['addons'].map { |it| AddonDetails.new(it) }
158
- @limits = List::ListLimitsReturned.new(hash['limits'])
162
+ def self.create(hash)
163
+ return nil if hash.nil?
164
+
165
+ addons = AddonDetails.create_list(hash['addons'])
166
+ limits = List::ListLimitsReturned.create(hash['limits'])
167
+ new(addons, limits)
159
168
  end
160
169
 
161
- def ==(other)
162
- compare(self, other)
170
+ def initialize(addons, limits)
171
+ @addons = addons
172
+ @limits = limits
163
173
  end
164
174
  end
165
175
 
@@ -169,12 +179,14 @@ module KodiClient
169
179
 
170
180
  attr_reader :addon
171
181
 
172
- def initialize(hash)
173
- @addon = AddonDetails.new(hash['addon'])
182
+ def self.create(hash)
183
+ return nil if hash.nil?
184
+
185
+ new(AddonDetails.create(hash['addon']))
174
186
  end
175
187
 
176
- def ==(other)
177
- compare(self, other)
188
+ def initialize(addon)
189
+ @addon = addon
178
190
  end
179
191
  end
180
192
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kodi_client/util/comparable'
4
4
  require 'kodi_client/util/iterable'
5
+ require 'kodi_client/util/creatable'
5
6
 
6
7
  module KodiClient
7
8
  module Types
@@ -22,35 +23,37 @@ module KodiClient
22
23
  # Application.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#Application.Property.Value
23
24
  class PropertyValue
24
25
  include Comparable
26
+ extend Creatable
25
27
 
26
28
  attr_reader :name, :version, :muted, :volume
27
29
 
28
- def initialize(hash)
29
- @name = hash['name']
30
- @version = hash['version'].nil? ? nil : Version.new(hash['version'])
31
- @muted = hash['muted']
32
- @volume = hash['volume']
30
+ def self.create(hash)
31
+ return null if hash.nil?
32
+
33
+ version = Version.create(hash['version'])
34
+ new(hash['name'], version, hash['muted'], hash['volume'])
33
35
  end
34
36
 
35
- def ==(other)
36
- compare(self, other)
37
+ def initialize(name, version, muted, volume)
38
+ @name = name
39
+ @version = version
40
+ @muted = muted
41
+ @volume = volume
37
42
  end
38
43
  end
39
44
 
40
45
  # represent application properties version
41
46
  class Version
42
47
  include Comparable
43
- attr_reader :major, :minor, :revision, :tag
48
+ extend Creatable
44
49
 
45
- def initialize(hash)
46
- @major = hash['major']
47
- @minor = hash['minor']
48
- @revision = hash['revision']
49
- @tag = hash['tag']
50
- end
50
+ attr_reader :major, :minor, :revision, :tag
51
51
 
52
- def ==(other)
53
- compare(self, other)
52
+ def initialize(major, minor, revision, tag)
53
+ @major = major
54
+ @minor = minor
55
+ @revision = revision
56
+ @tag = tag
54
57
  end
55
58
  end
56
59
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'kodi_client/global_types/media_types'
4
- require 'kodi_client/global_types/player_type'
5
4
  require 'kodi_client/util/comparable'
6
5
  require 'kodi_client/util/iterable'
6
+ require 'kodi_client/util/creatable'
7
7
 
8
8
  module KodiClient
9
9
  module Types
@@ -12,18 +12,15 @@ module KodiClient
12
12
  # Audio.Contributor https://kodi.wiki/view/JSON-RPC_API/v12#Audio.Contributors
13
13
  class AudioContributor
14
14
  include Comparable
15
+ extend Creatable
15
16
 
16
17
  attr_reader :artist_id, :name, :role, :role_id
17
18
 
18
- def initialize(hash)
19
- @artist_id = hash['artistid']
20
- @name = hash['name']
21
- @role = hash['role']
22
- @role_id = hash['roleid']
23
- end
24
-
25
- def ==(other)
26
- compare(self, other)
19
+ def initialize(artist_id, name, role, role_id)
20
+ @artist_id = artist_id
21
+ @name = name
22
+ @role = role
23
+ @role_id = role_id
27
24
  end
28
25
  end
29
26
 
@@ -41,11 +38,16 @@ module KodiClient
41
38
 
42
39
  attr_reader :art, :date_added, :genre
43
40
 
44
- def audio_details_base(hash)
45
- @art = Types::Media::MediaArtwork.new(hash['art'])
46
- @date_added = hash['date_added']
47
- @genre = hash['genre']
48
- media_details_base(hash)
41
+ def audio_details_base_by_hash(hash)
42
+ audio_details_base(Types::Media::MediaArtwork.create(hash['art']), hash['date_added'], hash['genre'],
43
+ *Creatable.hash_to_arr(hash, %w[fan_art thumbnail label]))
44
+ end
45
+
46
+ def audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
47
+ @art = art
48
+ @date_added = date_added
49
+ @genre = genre
50
+ media_details_base(fan_art, thumbnail, label)
49
51
  end
50
52
  end
51
53
 
@@ -53,23 +55,32 @@ module KodiClient
53
55
  module AudioDetailsMedia
54
56
  include AudioDetailsBase
55
57
 
56
- attr_reader :artist, :artist_id, :display_artist, :musicbrainz_albumartist_id, :original_date, :rating,
58
+ attr_reader :artist, :artist_id, :display_artist, :musicbrainz_album_artist_id, :original_date, :rating,
57
59
  :release_date, :sort_artist, :title, :user_rating, :votes, :year
58
60
 
59
- def audio_details_media(hash)
60
- @artist = hash['artist']
61
- @artist_id = hash['artistid']
62
- @display_artist = hash['displayartist']
63
- @musicbrainz_albumartist_id = hash['musicbrainzalbumartistid']
64
- @original_date = hash['originaldate']
65
- @rating = hash['rating']
66
- @release_date = hash['releasedate']
67
- @sort_artist = hash['sortartist']
68
- @title = hash['title']
69
- @user_rating = hash['userrating']
70
- @votes = hash['votes']
71
- @year = hash['year']
72
- audio_details_base(hash)
61
+ def audio_details_media_by_hash(hash)
62
+ audio_details_media(hash['artist'], hash['artistid'], hash['displayartist'], hash['musicbrainzalbumartistid'],
63
+ hash['originaldate'], hash['rating'], hash['releasedate'], hash['sortartist'],
64
+ hash['title'], hash['userrating'], hash['votes'], hash['year'],
65
+ *Creatable.hash_to_arr(hash, %w[art date_added genre fan_art thumbnail label]))
66
+ end
67
+
68
+ def audio_details_media(artist, artist_id, display_artist, musicbrainz_album_artist_id, original_date,
69
+ rating, release_date, sort_artist, title, user_rating, votes, year,
70
+ art, date_added, genre, fan_art, thumbnail, label)
71
+ @artist = artist
72
+ @artist_id = artist_id
73
+ @display_artist = display_artist
74
+ @musicbrainz_album_artist_id = musicbrainz_album_artist_id
75
+ @original_date = original_date
76
+ @rating = rating
77
+ @release_date = release_date
78
+ @sort_artist = sort_artist
79
+ @title = title
80
+ @user_rating = user_rating
81
+ @votes = votes
82
+ @year = year
83
+ audio_details_base(art, date_added, genre, fan_art, thumbnail, label)
73
84
  end
74
85
  end
75
86
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kodi_client/util/comparable'
4
4
  require 'kodi_client/util/iterable'
5
+ require 'kodi_client/util/creatable'
5
6
  require 'kodi_client/global_types/list_types'
6
7
 
7
8
  module KodiClient
@@ -30,38 +31,38 @@ module KodiClient
30
31
  end
31
32
 
32
33
  # Favourite.Details.Favourite https://kodi.wiki/view/JSON-RPC_API/v12#Favourite.Details.Favourite
33
- class Favourite
34
+ class DetailsFavourite
34
35
  include Comparable
36
+ extend Creatable
35
37
 
36
38
  attr_reader :path, :thumbnail, :title, :type, :window, :window_parameter
37
39
 
38
- def initialize(hash)
39
- @path = hash['path']
40
- @thumbnail = hash['thumbnail']
41
- @title = hash['title']
42
- @type = hash['type']
43
- @window = hash['window']
44
- @window_parameter = hash['windowparameter']
45
- end
46
-
47
- def ==(other)
48
- compare(self, other)
40
+ def initialize(path, thumbnail, title, type, window, window_parameter)
41
+ @path = path
42
+ @thumbnail = thumbnail
43
+ @title = title
44
+ @type = type
45
+ @window = window
46
+ @window_parameter = window_parameter
49
47
  end
50
48
  end
51
49
 
52
50
  # return type for Favourites.GetFavourites
53
51
  class GetFavouriteReturned
54
52
  include Comparable
53
+ extend Creatable
55
54
 
56
55
  attr_reader :favourites, :limits
57
56
 
58
- def initialize(hash)
59
- @favourites = hash['favourites'].map { |it| Favourite.new(it) }
60
- @limits = Types::List::ListLimitsReturned.new(hash['limits'])
57
+ def self.create(hash)
58
+ favourites = DetailsFavourite.create_list(hash['favourites'])
59
+ limits = Types::List::ListLimitsReturned.create(hash['limits'])
60
+ new(favourites, limits)
61
61
  end
62
62
 
63
- def ==(other)
64
- compare(self, other)
63
+ def initialize(favourites, limits)
64
+ @favourites = favourites
65
+ @limits = limits
65
66
  end
66
67
  end
67
68
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kodi_client/util/comparable'
4
4
  require 'kodi_client/util/iterable'
5
+ require 'kodi_client/util/creatable'
5
6
 
6
7
  module KodiClient
7
8
  module Types
@@ -9,7 +10,7 @@ module KodiClient
9
10
 
10
11
  # Global.Toggle https://kodi.wiki/view/JSON-RPC_API/v12#Global.Toggle
11
12
  module Toggle
12
- include Iterable
13
+ extend Iterable
13
14
 
14
15
  TOGGLE = 'toggle'
15
16
  TRUE = true
@@ -18,7 +19,7 @@ module KodiClient
18
19
 
19
20
  # rotate for clockwise and counter clockwise
20
21
  module Rotate
21
- include Iterable
22
+ extend Iterable
22
23
 
23
24
  CLOCKWISE = 'clockwise'
24
25
  COUNTER_CLOCKWISE = 'counterclockwise'
@@ -26,7 +27,7 @@ module KodiClient
26
27
 
27
28
  # direction for left, right, up, down
28
29
  module Direction
29
- include Iterable
30
+ extend Iterable
30
31
 
31
32
  LEFT = 'left'
32
33
  RIGHT = 'right'
@@ -36,7 +37,7 @@ module KodiClient
36
37
 
37
38
  # enum for prev/next
38
39
  module NextPrev
39
- include Iterable
40
+ extend Iterable
40
41
 
41
42
  NEXT = 'next'
42
43
  PREV = 'previous'
@@ -46,7 +47,7 @@ module KodiClient
46
47
 
47
48
  # Global.IncrementDecrement https://kodi.wiki/view/JSON-RPC_API/v12#Global.IncrementDecrement
48
49
  module IncrementDecrement
49
- include Iterable
50
+ extend Iterable
50
51
 
51
52
  INCREMENT = 'increment'
52
53
  DECREMENT = 'decrement'
@@ -55,49 +56,50 @@ module KodiClient
55
56
  # id/label type
56
57
  class IdLabel
57
58
  include Comparable
58
- attr_reader :id, :label
59
+ extend Creatable
59
60
 
60
- def initialize(hash)
61
- @id = hash['id']
62
- @label = hash['label']
63
- end
61
+ attr_reader :id, :label
64
62
 
65
- def ==(other)
66
- compare(self, other)
63
+ def initialize(id, label)
64
+ @id = id
65
+ @label = label
67
66
  end
68
67
  end
69
68
 
70
69
  # id/name type
71
70
  class IdName
72
71
  include Comparable
73
- attr_reader :id, :name
72
+ extend Creatable
74
73
 
75
- def initialize(hash)
76
- @id = hash['id']
77
- @name = hash['name']
78
- end
74
+ attr_reader :id, :name
79
75
 
80
- def ==(other)
81
- compare(self, other)
76
+ def initialize(id, name)
77
+ @id = id
78
+ @name = name
82
79
  end
83
80
  end
84
81
 
85
82
  # Global.Time https://kodi.wiki/view/JSON-RPC_API/v12#Global.Time
86
83
  class GlobalTime
87
84
  include Comparable
85
+ extend Creatable
88
86
 
89
87
  attr_reader :hours, :minutes, :seconds, :milliseconds
90
88
 
91
- def initialize(hash)
92
- @hours = hash['hours']
93
- @minutes = hash['minutes']
94
- @seconds = hash['seconds']
95
- @milliseconds = hash['milliseconds']
89
+ def initialize(hours, minutes, seconds, milliseconds)
90
+ @hours = hours
91
+ @minutes = minutes
92
+ @seconds = seconds
93
+ @milliseconds = milliseconds
96
94
  end
95
+ end
97
96
 
98
- def ==(other)
99
- compare(self, other)
100
- end
97
+ # available Password Encryptions
98
+ module PasswordEncryption
99
+ extend Iterable
100
+
101
+ NONE = 'none'
102
+ MD5 = 'md5'
101
103
  end
102
104
  end
103
105
  end
@@ -3,6 +3,7 @@
3
3
  require 'kodi_client/global_types/global_types'
4
4
  require 'kodi_client/util/comparable'
5
5
  require 'kodi_client/util/iterable'
6
+ require 'kodi_client/util/creatable'
6
7
 
7
8
  module KodiClient
8
9
  module Types
@@ -10,6 +11,7 @@ module KodiClient
10
11
 
11
12
  # GUI.Window https://kodi.wiki/view/JSON-RPC_API/v12#GUI.Window
12
13
  module GUIWindow
14
+ extend Iterable
13
15
 
14
16
  ACCESSPOINTS = 'accesspoints'
15
17
  ADDON = 'addon'
@@ -139,6 +141,7 @@ module KodiClient
139
141
  class StereoscopyMode
140
142
  include Comparable
141
143
  include Iterable
144
+ extend Creatable
142
145
 
143
146
  attr_reader :label, :mode
144
147
 
@@ -152,32 +155,35 @@ module KodiClient
152
155
  ANAGLYPH_YELLOW_BLUE = 'anaglyph_yellow_blue'
153
156
  MONSCOPIC = 'monoscopic'
154
157
 
155
- def initialize(hash)
156
- @label = hash['label']
157
- @mode = hash['mode']
158
- end
159
-
160
- def ==(other)
161
- compare(self, other)
158
+ def initialize(label, mode)
159
+ @label = label
160
+ @mode = mode
162
161
  end
163
162
  end
164
163
 
165
164
  # GUI.Property.Value https://kodi.wiki/view/JSON-RPC_API/v12#GUI.Property.Value
166
165
  class PropertyValue
167
166
  include Comparable
167
+ extend Creatable
168
168
 
169
169
  attr_reader :current_control, :current_window, :fullscreen, :skin, :stereoscopic_mode
170
170
 
171
- def initialize(hash)
172
- @current_control = Global::IdLabel.new(hash['currentcontrol'])
173
- @current_window = Global::IdLabel.new(hash['currentwindow'])
174
- @fullscreen = hash['fullscreen']
175
- @skin = Global::IdName.new(hash['skin'])
176
- @stereoscopic_mode = StereoscopyMode.new(hash['stereoscopicmode'])
171
+ def self.create(hash)
172
+ return nil if hash.nil?
173
+
174
+ current_control = Global::IdLabel.create(hash['currentcontrol'])
175
+ current_window = Global::IdLabel.create(hash['currentwindow'])
176
+ skin = Global::IdName.create(hash['skin'])
177
+ stereoscopic_mode = StereoscopyMode.create(hash['stereoscopicmode'])
178
+ new(current_control, current_window, hash['fullscreen'], skin, stereoscopic_mode)
177
179
  end
178
180
 
179
- def ==(other)
180
- compare(self, other)
181
+ def initialize(current_control, current_window, fullscreen, skin, stereoscopic_mode)
182
+ @current_control = current_control
183
+ @current_window = current_window
184
+ @fullscreen = fullscreen
185
+ @skin = skin
186
+ @stereoscopic_mode = stereoscopic_mode
181
187
  end
182
188
  end
183
189
  end