Class: MoveAction

Inherits:
AbstractAction
  • Object
show all
Defined in:
lib/life_game_viewer/view/actions.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_model) ⇒ MoveAction

Returns a new instance of MoveAction.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/life_game_viewer/view/actions.rb', line 25

def initialize(table_model)
  super(caption)  # caption implemented by subclasses
  @table_model = table_model

  # should_be_enabled? below needs to be implemented by subclasses
  enabled_updater = lambda do |current_generation_num|
    self.enabled = should_be_enabled?
  end

  @table_model.add_current_num_change_handler(enabled_updater)

  self.enabled = enabled_updater.call(nil)
end

Instance Method Details

#actionPerformed(event) ⇒ Object



39
40
41
42
# File 'lib/life_game_viewer/view/actions.rb', line 39

def actionPerformed(event)
  move  # implemented by subclasses
  @table_model.fire_table_data_changed
end