class Action
An Action
is executed on a user's request. It has a name, an associated closure and hotkey.
Attributes
global[RW]
key[RW]
name[RW]
proc[RW]
Public Class Methods
new(options = {}, &b)
click to toggle source
# File lib/action.rb, line 41 def initialize(options = {}, &b) init_logger(STDOUT, Logger::INFO) @name = options[:name] @key = options[:key] @proc = b if b @global = options[:global] @hidden = options[:hidden] end
Public Instance Methods
call(*args)
click to toggle source
# File lib/action.rb, line 51 def call(*args) unless @proc raise ActionError.new((@name ? '' : 'Unnamed ') << 'action' << (@name ? (' ' << @name) : '') << ' called before a command was defined') end @proc.call(*args) end
to_s()
click to toggle source
# File lib/action.rb, line 36 def to_s "[#<" << classname << ':' << hash << '@name="' << name << '", @key="' << key << '">' end