Class: AppleBot::Command
- Inherits:
-
Struct
- Object
- Struct
- AppleBot::Command
- Defined in:
- lib/applebot/commands.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#description ⇒ Object
Returns the value of attribute description.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #cli_command ⇒ Object
-
#initialize(*properties) ⇒ Command
constructor
A new instance of Command.
- #ruby_method ⇒ Object
Constructor Details
#initialize(*properties) ⇒ Command
Returns a new instance of Command.
5 6 7 8 9 |
# File 'lib/applebot/commands.rb', line 5 def initialize(*properties) = properties.delete_at -1 super(*properties) self. = CommandOptionSet.new(['required'], ['optional']) end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action
4 5 6 |
# File 'lib/applebot/commands.rb', line 4 def action @action end |
#description ⇒ Object
Returns the value of attribute description
4 5 6 |
# File 'lib/applebot/commands.rb', line 4 def description @description end |
#file_name ⇒ Object
Returns the value of attribute file_name
4 5 6 |
# File 'lib/applebot/commands.rb', line 4 def file_name @file_name end |
#namespace ⇒ Object
Returns the value of attribute namespace
4 5 6 |
# File 'lib/applebot/commands.rb', line 4 def namespace @namespace end |
#options ⇒ Object
Returns the value of attribute options
4 5 6 |
# File 'lib/applebot/commands.rb', line 4 def @options end |
Class Method Details
.load_all! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/applebot/commands.rb', line 11 def self.load_all! commands_file_path = File.join(AppleBot.phantom_scripts_path, '_commands.json') commands = JSON.parse(IO.read(commands_file_path)) AppleBot.commands = commands.keys.map {|file| command_config = commands[file] args = [file] + [ command_config['namespace'], command_config['action'], command_config['description'], command_config['options'] ] Command.new(*args) } end |
Instance Method Details
#cli_command ⇒ Object
24 25 26 |
# File 'lib/applebot/commands.rb', line 24 def cli_command "#{namespace}:#{action}" end |
#ruby_method ⇒ Object
28 29 30 |
# File 'lib/applebot/commands.rb', line 28 def ruby_method "#{action}_#{namespace}" end |