Module: CultomePlayer::Plugins

Includes:
Alias, Gestures, Help, KeyboardSpecialKeys, Points
Included in:
CultomePlayer
Defined in:
lib/cultome_player/plugins.rb,
lib/cultome_player/plugins/help.rb,
lib/cultome_player/plugins/alias.rb,
lib/cultome_player/plugins/points.rb,
lib/cultome_player/plugins/gestures.rb,
lib/cultome_player/plugins/keyboard_special_keys.rb

Defined Under Namespace

Modules: Alias, Gestures, Help, KeyboardSpecialKeys, Points

Instance Method Summary collapse

Methods included from KeyboardSpecialKeys

#init_plugin_keyboard_special_keys

Methods included from Gestures

#init_plugin_gestures

Methods included from Points

#init_plugin_points

Methods included from Alias

#command_alias, #description_alias, #respond_to?, #sintax_alias, #usage_alias

Methods included from Help

#command_help, #description_help, #sintax_help, #usage_help

Instance Method Details

#clean_pluginsObject



45
46
47
# File 'lib/cultome_player/plugins.rb', line 45

def clean_plugins
  methods.grep(/^clean_plugin_/).each{|method_name| send(method_name) }
end

#init_pluginsObject

Call init_plugin_<action> to initialize all the plugins that require it.



41
42
43
# File 'lib/cultome_player/plugins.rb', line 41

def init_plugins
  methods.grep(/^init_plugin_/).each{|method_name| send(method_name) }
end

#plugin_command_sintax(cmd_name) ⇒ Regex

Get a command format for a command implemented by a plugin

Parameters:

  • cmd_name (String)

    The command name.

Returns:

  • (Regex)

    The regex to validate a command format that is implemented by a plugin.



27
28
29
# File 'lib/cultome_player/plugins.rb', line 27

def plugin_command_sintax(cmd_name)
  return send("sintax_#{cmd_name}".to_sym)
end

#plugin_config(plugin_name) ⇒ Hash

Lazy getter for plugins configurator. Its a persistent store where plugin can put their configurations.

Parameters:

  • plugin_name (#to_s)

    The name of the plugin.

Returns:

  • (Hash)

    Where plugins can stores their information.



35
36
37
38
# File 'lib/cultome_player/plugins.rb', line 35

def plugin_config(plugin_name)
  plugin_ns = player_config['plugins'] ||= {}
  return plugin_ns[plugin_name.to_s] ||= {}
end

#plugins_respond_to?(cmd_name) ⇒ Boolean

Check if a plugin implements the given command.

Parameters:

  • cmd_name (String)

    The command name.

Returns:

  • (Boolean)

    True is the given command is implemented by a plugin.



19
20
21
# File 'lib/cultome_player/plugins.rb', line 19

def plugins_respond_to?(cmd_name)
  return respond_to?("command_#{cmd_name}".to_sym)
end