Class: VER::Undo::AutoSeparator

Inherits:
Struct
  • Object
show all
Defined in:
lib/ver/undo.rb

Overview

Tree

Constant Summary

Constants inherited from Struct

Struct::CACHE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

new

Constructor Details

#initialize(tree) {|_self| ... } ⇒ AutoSeparator

Returns a new instance of AutoSeparator.

Yields:

  • (_self)

Yield Parameters:



106
107
108
109
110
111
112
113
# File 'lib/ver/undo.rb', line 106

def initialize(tree)
  self.tree = tree
  self.records = []

  yield(self) if block_given?

  records.last.separator = true if records.any?
end

Instance Attribute Details

#recordsObject

Returns the value of attribute records

Returns:

  • (Object)

    the current value of records



105
106
107
# File 'lib/ver/undo.rb', line 105

def records
  @records
end

#treeObject

Returns the value of attribute tree

Returns:

  • (Object)

    the current value of tree



105
106
107
# File 'lib/ver/undo.rb', line 105

def tree
  @tree
end

Instance Method Details

#delete(*args) ⇒ Object



129
130
131
132
133
134
# File 'lib/ver/undo.rb', line 129

def delete(*args)
  tree.record do |record|
    record.delete(*args)
    records << record
  end
end

#insert(*args) ⇒ Object



115
116
117
118
119
120
# File 'lib/ver/undo.rb', line 115

def insert(*args)
  tree.record do |record|
    record.insert(*args)
    records << record
  end
end

#replace(*args) ⇒ Object



122
123
124
125
126
127
# File 'lib/ver/undo.rb', line 122

def replace(*args)
  tree.record do |record|
    record.replace(*args)
    records << record
  end
end