Class: CommandBot::Command
- Inherits:
-
Object
- Object
- CommandBot::Command
- Defined in:
- lib/command_bot/command.rb
Overview
Stores command handler.
Instance Attribute Summary collapse
- #aliases ⇒ Array<String> readonly
- #data ⇒ Hash readonly
- #handler ⇒ Proc readonly
- #name ⇒ String readonly
Instance Method Summary collapse
- #all_aliases ⇒ Array<String>
-
#initialize(name: '', aliases: [], data: {}) {|bot, arguments, options, other| ... } ⇒ Command
constructor
Initalize new command.
- #name_matches?(*names) ⇒ Boolean
Constructor Details
#initialize(name: '', aliases: [], data: {}) {|bot, arguments, options, other| ... } ⇒ Command
Initalize new command.
15 16 17 18 19 20 21 |
# File 'lib/command_bot/command.rb', line 15 def initialize(name: '', aliases: [], data: {}, &handler) @name = name @aliases = aliases @data = data @handler = handler end |
Instance Attribute Details
#aliases ⇒ Array<String> (readonly)
27 28 29 |
# File 'lib/command_bot/command.rb', line 27 def aliases @aliases end |
#data ⇒ Hash (readonly)
30 31 32 |
# File 'lib/command_bot/command.rb', line 30 def data @data end |
#handler ⇒ Proc (readonly)
33 34 35 |
# File 'lib/command_bot/command.rb', line 33 def handler @handler end |
#name ⇒ String (readonly)
24 25 26 |
# File 'lib/command_bot/command.rb', line 24 def name @name end |
Instance Method Details
#all_aliases ⇒ Array<String>
36 37 38 |
# File 'lib/command_bot/command.rb', line 36 def all_aliases aliases + [name] end |
#name_matches?(*names) ⇒ Boolean
42 43 44 |
# File 'lib/command_bot/command.rb', line 42 def name_matches?(*names) all_aliases.any? { |a| names.include?(a) } end |