Class: Twisty::Command
- Inherits:
-
Object
- Object
- Twisty::Command
- Defined in:
- lib/twisty/command.rb
Overview
Used to provide the descriptions, examples of and executable code of commands that the player can type.
Instance Attribute Summary collapse
-
#help1 ⇒ Object
readonly
(
String) An example of the command e.g. -
#help2 ⇒ Object
readonly
(
String) Short description of what the command actually does.
Instance Method Summary collapse
-
#exec(args) ⇒ Object
Executes this instance of command.
-
#initialize(help1, help2, func) ⇒ Command
constructor
Initialiser.
Constructor Details
#initialize(help1, help2, func) ⇒ Command
Initialiser. Use Engine.define_command() instead
- help1
-
(
String) An example of the command e.g. “take item” - help2
-
(
String) Short description of what the command actually does - func
-
(Proc) Code that provides the commands effect(s). NOTE This
must take exactly one argument of type +Array+[+String+]
30 31 32 33 34 35 |
# File 'lib/twisty/command.rb', line 30 def initialize(help1, help2, func) @help1 = help1 @help2 = help2 self.define_singleton_method(:exec, func) end |
Instance Attribute Details
#help1 ⇒ Object (readonly)
(String) An example of the command e.g. “take item”
20 21 22 |
# File 'lib/twisty/command.rb', line 20 def help1 @help1 end |
#help2 ⇒ Object (readonly)
(String) Short description of what the command actually does
22 23 24 |
# File 'lib/twisty/command.rb', line 22 def help2 @help2 end |
Instance Method Details
#exec(args) ⇒ Object
Executes this instance of command. This is redefined on a per-instance basis by Command.new().
- args
-
(
Array[String]) Words the player typed in
41 42 43 |
# File 'lib/twisty/command.rb', line 41 def exec(args) return end |