Class: Gamefic::Command
- Inherits:
-
Object
- Object
- Gamefic::Command
- Defined in:
- lib/gamefic/command.rb
Overview
A concrete representation of an input as a verb and an array of arguments.
Instance Attribute Summary collapse
- #arguments ⇒ Array<Array<Entity>, Entity, String> readonly
- #input ⇒ String? readonly
- #verb ⇒ Symbol readonly
Instance Method Summary collapse
- #active? ⇒ Boolean
- #cancel ⇒ Object (also: #stop)
- #cancelled? ⇒ Boolean (also: #stopped?)
-
#initialize(verb, arguments, meta = false, input = nil) ⇒ Command
constructor
A new instance of Command.
- #inspect ⇒ Object
- #meta? ⇒ Boolean
Constructor Details
#initialize(verb, arguments, meta = false, input = nil) ⇒ Command
20 21 22 23 24 25 26 |
# File 'lib/gamefic/command.rb', line 20 def initialize(verb, arguments, = false, input = nil) @verb = verb @arguments = arguments @meta = @input = input @cancelled = false end |
Instance Attribute Details
#arguments ⇒ Array<Array<Entity>, Entity, String> (readonly)
11 12 13 |
# File 'lib/gamefic/command.rb', line 11 def arguments @arguments end |
#input ⇒ String? (readonly)
14 15 16 |
# File 'lib/gamefic/command.rb', line 14 def input @input end |
#verb ⇒ Symbol (readonly)
8 9 10 |
# File 'lib/gamefic/command.rb', line 8 def verb @verb end |
Instance Method Details
#active? ⇒ Boolean
42 43 44 |
# File 'lib/gamefic/command.rb', line 42 def active? ! end |
#cancel ⇒ Object Also known as: stop
28 29 30 |
# File 'lib/gamefic/command.rb', line 28 def cancel @cancelled = true end |
#cancelled? ⇒ Boolean Also known as: stopped?
33 34 35 |
# File 'lib/gamefic/command.rb', line 33 def cancelled? @cancelled end |
#inspect ⇒ Object
46 47 48 |
# File 'lib/gamefic/command.rb', line 46 def inspect "#<#{self.class} #{([verb] + arguments).map(&:inspect).join(', ')}>" end |
#meta? ⇒ Boolean
38 39 40 |
# File 'lib/gamefic/command.rb', line 38 def @meta end |