Class: TreeDelta::Intermediate
- Inherits:
-
Object
- Object
- TreeDelta::Intermediate
- Defined in:
- lib/tree_delta/intermediate.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #attaches ⇒ Object
- #creates ⇒ Object
- #deletes ⇒ Object
- #detaches ⇒ Object
-
#initialize(from:, to:) ⇒ Intermediate
constructor
A new instance of Intermediate.
- #updates ⇒ Object
Constructor Details
#initialize(from:, to:) ⇒ Intermediate
Returns a new instance of Intermediate.
5 6 7 |
# File 'lib/tree_delta/intermediate.rb', line 5 def initialize(from:, to:) @from, @to = from, to end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
3 4 5 |
# File 'lib/tree_delta/intermediate.rb', line 3 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
3 4 5 |
# File 'lib/tree_delta/intermediate.rb', line 3 def to @to end |
Instance Method Details
#attaches ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/tree_delta/intermediate.rb', line 59 def attaches Enumerator.new do |y| moves.each do |node| unless root?(node) y.yield TreeDelta::Operation.new( type: :attach, identity: node.identity, parent: parent_identity(node), position: position(node) ) end end end end |
#creates ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tree_delta/intermediate.rb', line 9 def creates Enumerator.new do |y| additions.each do |node| y.yield TreeDelta::Operation.new( type: :create, identity: node.identity, value: node.value, parent: parent_identity(node), position: position(node) ) end end end |
#deletes ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tree_delta/intermediate.rb', line 35 def deletes Enumerator.new do |y| normalised_deletions.each do |node| y.yield TreeDelta::Operation.new( type: :delete, identity: node.identity ) end end end |