Class: Kodi::NamespaceBuilder

Inherits:
Struct
  • Object
show all
Defined in:
lib/kodi/namespace_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#uriObject

Returns the value of attribute uri

Returns:

  • (Object)

    the current value of 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
# 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