Class: Mysh::Action

Inherits:
Object show all
Defined in:
lib/mysh/action.rb

Overview

The mysh internal action class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = "", description = "", &action) ⇒ Action

Setup an internal action.



15
16
17
18
19
# File 'lib/mysh/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

#descriptionObject (readonly)

The description of the action.



12
13
14
# File 'lib/mysh/action.rb', line 12

def description
  @description
end

#nameObject (readonly)

The name of the action.



9
10
11
# File 'lib/mysh/action.rb', line 9

def name
  @name
end

Instance Method Details

#action_infoObject

Get information about the action.



28
29
30
# File 'lib/mysh/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/action.rb', line 22

def process_quick_command(input)
  process_command(input.quick)
  :internal
end

#short_nameObject

Get the name without any argument descriptions.



33
34
35
# File 'lib/mysh/action.rb', line 33

def short_name
  name.split[0] || ""
end