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.



1490
1491
1492
1493
# File 'lib/textbringer/buffer.rb', line 1490

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

Instance Method Details

#add_action(action) ⇒ Object



1495
1496
1497
# File 'lib/textbringer/buffer.rb', line 1495

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

#redoObject



1505
1506
1507
1508
1509
# File 'lib/textbringer/buffer.rb', line 1505

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

#undoObject



1499
1500
1501
1502
1503
# File 'lib/textbringer/buffer.rb', line 1499

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