Class: MobSpawner::Command
- Inherits:
-
Object
- Object
- MobSpawner::Command
- Defined in:
- lib/mob_spawner.rb
Overview
Represents a command to be called by the spawner. Can also hold environment variables and arbitrary client data to identify the object.
Instance Attribute Summary collapse
-
#command ⇒ String
The command to be executed by the spawner.
-
#data ⇒ Object
Arbitrary client data used to identify the command object.
-
#env ⇒ Hash{String=>String}
Any environment variables to be set when running the command.
Instance Method Summary collapse
-
#initialize(cmd, env = {}, data = nil) ⇒ Command
constructor
Creates a new command.
Constructor Details
#initialize(opts = {}) ⇒ Command #initialize(cmd, env = {}, data = nil) ⇒ Command
Creates a new command.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mob_spawner.rb', line 34 def initialize(cmd, env = {}, data = nil) self.env = {} if cmd.is_a?(Hash) cmd.each do |k, v| meth = "#{k}=" send(meth, v) if respond_to?(meth) end else self.command = cmd self.env = env self.data = data end end |
Instance Attribute Details
#command ⇒ String
Returns the command to be executed by the spawner.
13 14 15 |
# File 'lib/mob_spawner.rb', line 13 def command @command end |
#data ⇒ Object
Returns arbitrary client data used to identify the command object.
21 22 23 |
# File 'lib/mob_spawner.rb', line 21 def data @data end |
#env ⇒ Hash{String=>String}
Returns any environment variables to be set when running the command.
17 18 19 |
# File 'lib/mob_spawner.rb', line 17 def env @env end |