Class: Kodi::NamespaceBuilder
- Inherits:
-
Struct
- Object
- Struct
- Kodi::NamespaceBuilder
- Defined in:
- lib/kodi/namespace_builder.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#build_namespaces(method_groups = nil) ⇒ Object
Generates a hash of Namespaces by name for a particular URI.
Instance Attribute Details
#uri ⇒ Object
Returns the value of attribute uri
2 3 4 |
# File 'lib/kodi/namespace_builder.rb', line 2 def uri @uri end |
Instance Method Details
#build_namespaces(method_groups = nil) ⇒ Object
Generates a hash of Namespaces by name for a particular URI
Params
method_groups
(optional)-
A Hash where the key is the name of the created namespace and the value is an Array of the desired methods. A valid hash could be:
'AudioLibrary' => ['GetArtists'], 'Input' => ['Up', 'Down', 'Left', 'Right', 'Select', 'Back'], 'Player' => ['GetActivePlayers', 'PlayPause']
If left empty, the complete API will be requested from the server. This will cost an extra second or two, but ensures that you have all methods available.
15 16 17 18 19 20 21 22 |
# File 'lib/kodi/namespace_builder.rb', line 15 def build_namespaces(method_groups = nil) method_groups = to_structs(method_groups) if method_groups namespaces = (method_groups || api_method_groups).map do |name, methods| Namespace.new(uri, name, *methods) end namespaces.index_by(&:name) end |