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.



1842
1843
1844
1845
# File 'lib/textbringer/buffer.rb', line 1842

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

Instance Method Details

#add_action(action) ⇒ Object



1847
1848
1849
# File 'lib/textbringer/buffer.rb', line 1847

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

#redoObject



1857
1858
1859
1860
1861
# File 'lib/textbringer/buffer.rb', line 1857

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

#undoObject



1851
1852
1853
1854
1855
# File 'lib/textbringer/buffer.rb', line 1851

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