Class: LiabilityProof::Tree::InternalNode

Inherits:
Struct
  • Object
show all
Includes:
Node
Defined in:
lib/liability-proof/tree/internal_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Node

#as_json, #as_user_json, #decimal_to_digits, #sum_string

Constructor Details

#initialize(left, right) ⇒ InternalNode

Returns a new instance of InternalNode.



7
8
9
10
11
12
# File 'lib/liability-proof/tree/internal_node.rb', line 7

def initialize(left, right)
  super(left, right)

  self.sum = left.sum + right.sum
  self.hash  = generate_hash
end

Instance Attribute Details

#hashObject

Returns the value of attribute hash

Returns:

  • (Object)

    the current value of hash



4
5
6
# File 'lib/liability-proof/tree/internal_node.rb', line 4

def hash
  @hash
end

#leftObject

Returns the value of attribute left

Returns:

  • (Object)

    the current value of left



4
5
6
# File 'lib/liability-proof/tree/internal_node.rb', line 4

def left
  @left
end

#rightObject

Returns the value of attribute right

Returns:

  • (Object)

    the current value of right



4
5
6
# File 'lib/liability-proof/tree/internal_node.rb', line 4

def right
  @right
end

#sumObject

Returns the value of attribute sum

Returns:

  • (Object)

    the current value of sum



4
5
6
# File 'lib/liability-proof/tree/internal_node.rb', line 4

def sum
  @sum
end