Class: Steam::Plugins
- Inherits:
-
Object
- Object
- Steam::Plugins
- Includes:
- Enumerable
- Defined in:
- lib/steam/plugins.rb
Overview
Allows "plugins" via gems. The plugins are just gems that react to client events an maybe expose an additional api. For example a CSGO plugin would be respoinsible for strictly CSGO related things and could have syntatic candy for things such as logging the player on, and handling the connection flow of CSGO related connection events. It could also provide the abililty to send specific GC messages like the requesting of match info.
The plugins are refered to by name, ie: csgo
The CSGO plugin would be a gem that is named steam-csgo
and has the
following struture.
-steam-csgo
- lib
- steam
- csgo
- base.rb
- csgo.rb
- csgo
- steam
- ... other gem things ...
The fastpeek/steam-csgo gem is a CSGO plugin for references
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#loaded_plugins ⇒ Object
readonly
Returns the value of attribute loaded_plugins.
Instance Method Summary collapse
-
#initialize(client) ⇒ Plugins
constructor
Instantiate a new Plugins engine.
-
#load ⇒ Integer
Load the plugins.
-
#loaded?(plugin) ⇒ Bool
Determine if the Client has a plugin loaded.
-
#plugin(plugin) ⇒ Object
Add a plugin to the internal list.
Constructor Details
#initialize(client) ⇒ Plugins
Instantiate a new Plugins engine
30 31 32 33 34 35 36 |
# File 'lib/steam/plugins.rb', line 30 def initialize(client) @client = client @mutex = Mutex.new @plugins = [] @loaded_plugins = [] @loaded = false end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
27 28 29 |
# File 'lib/steam/plugins.rb', line 27 def client @client end |
#loaded_plugins ⇒ Object (readonly)
Returns the value of attribute loaded_plugins.
27 28 29 |
# File 'lib/steam/plugins.rb', line 27 def loaded_plugins @loaded_plugins end |
Instance Method Details
#load ⇒ Integer
Load the plugins. Attempt to require each plugin. If the require call fails an error message is printed.
If the client has already loaded the plugins, they are not loaded again.
59 60 61 62 63 64 65 66 |
# File 'lib/steam/plugins.rb', line 59 def load return true if @loaded @loaded_plugins = require_plugins Steam.logger.debug("Loaded plugins: #{loaded_plugins}") setup_plugin_helpers(loaded_plugins) @loaded = true @loaded_plugins.count >= 1 end |
#loaded?(plugin) ⇒ Bool
Determine if the Client has a plugin loaded
42 43 44 |
# File 'lib/steam/plugins.rb', line 42 def loaded?(plugin) @loaded_plugins.include?(plugin.to_sym) end |
#plugin(plugin) ⇒ Object
Add a plugin to the internal list. Plugins are not loaded until
load is called.
48 49 50 51 |
# File 'lib/steam/plugins.rb', line 48 def plugin(plugin) @plugins << plugin.to_sym @plugins end |