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.



2015
2016
2017
2018
# File 'lib/textbringer/buffer.rb', line 2015

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

Instance Method Details

#add_action(action) ⇒ Object



2020
2021
2022
# File 'lib/textbringer/buffer.rb', line 2020

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

#redoObject



2031
2032
2033
2034
2035
# File 'lib/textbringer/buffer.rb', line 2031

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

#undoObject



2024
2025
2026
2027
2028
2029
# File 'lib/textbringer/buffer.rb', line 2024

def undo
  @actions.reverse_each do |action|
    action.undo
  end
  @buffer.goto_char(@location)
end