Class: Textbringer::CompositeAction

Inherits:
UndoableAction show all
Defined in:
lib/textbringer/buffer.rb

Instance Attribute Summary

Attributes inherited from UndoableAction

#location, #version

Instance Method Summary collapse

Constructor Details

#initialize(buffer, location) ⇒ CompositeAction

Returns a new instance of CompositeAction.



1409
1410
1411
1412
# File 'lib/textbringer/buffer.rb', line 1409

def initialize(buffer, location)
  super(buffer, location)
  @actions = []
end

Instance Method Details

#add_action(action) ⇒ Object



1414
1415
1416
# File 'lib/textbringer/buffer.rb', line 1414

def add_action(action)
  @actions.push(action)
end

#redoObject



1424
1425
1426
1427
1428
# File 'lib/textbringer/buffer.rb', line 1424

def redo
  @actions.each do |action|
    action.redo
  end
end

#undoObject



1418
1419
1420
1421
1422
# File 'lib/textbringer/buffer.rb', line 1418

def undo
  @actions.reverse_each do |action|
    action.undo
  end
end