class Kodi::NamespaceBuilder
Public Instance Methods
build_namespaces(method_groups = nil)
click to toggle source
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.
# File lib/kodi/namespace_builder.rb, line 15 def build_namespaces(method_groups = nil) namespaces = (method_groups || api_method_groups).map do |name, methods| Namespace.new(uri, name, *methods) end namespaces.index_by(&:name) end
Private Instance Methods
api_introspect()
click to toggle source
# File lib/kodi/namespace_builder.rb, line 35 def api_introspect @api_introspect ||= RPC.new(uri).dispatch('JSONRPC.Introspect') end
api_method_groups()
click to toggle source
# File lib/kodi/namespace_builder.rb, line 25 def api_method_groups api_methods.group_by(&:namespace) end
api_methods()
click to toggle source
# File lib/kodi/namespace_builder.rb, line 29 def api_methods api_introspect['methods'].keys.map do |path| Struct.new(:namespace, :name).new(*path.split('.', 2)) end end