Class: Mysh::Action
- Defined in:
- lib/mysh/internal/action.rb,
lib/mysh/internal/actions/actions_path.rb
Overview
-
mysh/internal/actions/actions_path.rb – A convenient hook to the actions folder.
Direct Known Subclasses
CommandOption, EnvInfoCommand, GlsCommand, HelpCommand, HelpSubCommand, HistoryCommand, RubyInfoCommand, VarsCommand
Constant Summary collapse
- ACTIONS_PATH =
Capture this folder’s name.
File.dirname(__FILE__) + "/"
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
The description of the action.
-
#name ⇒ Object
readonly
The name of the action.
Instance Method Summary collapse
-
#action_info ⇒ Object
Get information about the action.
-
#initialize(name = "", description = "", &action) ⇒ Action
constructor
Setup an internal action.
-
#process_quick_command(input) ⇒ Object
Parse the string and call the action.
-
#short_name ⇒ Object
Get the name without any argument descriptions.
Constructor Details
#initialize(name = "", description = "", &action) ⇒ Action
Setup an internal action.
15 16 17 18 19 |
# File 'lib/mysh/internal/action.rb', line 15 def initialize(name = "", description = "", &action) @name, @description = name, description.in_array define_singleton_method(:process_command, &action) if block_given? end |
Instance Attribute Details
#description ⇒ Object (readonly)
The description of the action.
12 13 14 |
# File 'lib/mysh/internal/action.rb', line 12 def description @description end |
#name ⇒ Object (readonly)
The name of the action.
9 10 11 |
# File 'lib/mysh/internal/action.rb', line 9 def name @name end |
Instance Method Details
#action_info ⇒ Object
Get information about the action.
28 29 30 |
# File 'lib/mysh/internal/action.rb', line 28 def action_info [@name].concat(@description) end |
#process_quick_command(input) ⇒ Object
Parse the string and call the action.
22 23 24 25 |
# File 'lib/mysh/internal/action.rb', line 22 def process_quick_command(input) process_command(input.quick) :internal end |
#short_name ⇒ Object
Get the name without any argument descriptions.
33 34 35 |
# File 'lib/mysh/internal/action.rb', line 33 def short_name name.split[0] || "" end |