Class: RubyCurses::Action

Inherits:
Proc
  • Object
show all
Includes:
ConfigSetup, EventHandler
Defined in:
lib/rbcurse/action.rb

Overview

encapsulates behaviour allowing centralization

Example

a = Action.new("&New Row") { commands }
a.accelerator "Alt N"
menu.add(a)
b = Button.new form do
  action a
  ...
end

Instance Method Summary collapse

Methods included from ConfigSetup

#cget, #config_setup, #configure, #variable_set

Methods included from EventHandler

#bind, #fire_handler, #fire_property_change

Constructor Details

#initialize(name, config = {}, &block) ⇒ Action

Returns a new instance of Action.



25
26
27
28
29
30
31
32
# File 'lib/rbcurse/action.rb', line 25

def initialize name, config={}, &block
  super &block
  @name = name
  @name.freeze
  @enabled = true
  config_setup config # @config.each_pair { |k,v| variable_set(k,v) }
  @_events = [:FIRE]
end

Instance Method Details

#callObject



33
34
35
36
37
# File 'lib/rbcurse/action.rb', line 33

def call
  return unless @enabled
  fire_handler :FIRE, self
  super
end