class Mysh::ActionPool
A managed hash of mysh actions.
Attributes
pool_name[R]
The name of this action pool.
Public Class Methods
new(pool_name, default_action = nil)
click to toggle source
Create a new action pool
# File lib/mysh/action_pool.rb, line 13 def initialize(pool_name, default_action = nil) @pool_name, @pool = pool_name, {} @pool.default = default_action end
Public Instance Methods
[](index)
click to toggle source
Get a action.
# File lib/mysh/action_pool.rb, line 19 def [](index) @pool[index] end
actions_info()
click to toggle source
Get information on all actions.
# File lib/mysh/action_pool.rb, line 40 def actions_info @pool .values .map {|action| action.action_info} .sort {|first, second| first[0] <=> second[0]} end
add_action(action)
click to toggle source
Add an action to the pool.
# File lib/mysh/action_pool.rb, line 29 def add_action(action) short_name = action.short_name if @pool.key?(short_name) fail "Add error: Action #{short_name.inspect} already exists in #{pool_name}." end @pool[short_name] = action end
exists?(index)
click to toggle source
Does this action exist?
# File lib/mysh/action_pool.rb, line 24 def exists?(index) @pool.key?(index) end