Class: TreeDelta::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/tree_delta/operation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, identity:, value: nil, parent: nil, position: nil) ⇒ Operation

Returns a new instance of Operation.



5
6
7
8
9
10
11
# File 'lib/tree_delta/operation.rb', line 5

def initialize(type:, identity:, value: nil, parent: nil, position: nil)
  @type     = type
  @identity = identity
  @value    = value    if value
  @parent   = parent   if parent
  @position = position if position
end

Instance Attribute Details

#identityObject (readonly)

Returns the value of attribute identity.



3
4
5
# File 'lib/tree_delta/operation.rb', line 3

def identity
  @identity
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/tree_delta/operation.rb', line 3

def parent
  @parent
end

#positionObject (readonly)

Returns the value of attribute position.



3
4
5
# File 'lib/tree_delta/operation.rb', line 3

def position
  @position
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/tree_delta/operation.rb', line 3

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/tree_delta/operation.rb', line 3

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/tree_delta/operation.rb', line 13

def ==(other)
  @type       == other.type     &&
    @identity == other.identity &&
    @value    == other.value    &&
    @parent   == other.parent   &&
    @position == other.position
end