class MerkleTree::Node

Attributes

left[R]
right[R]
value[R]

Public Class Methods

new( value, left, right ) click to toggle source
# File lib/merkletree.rb, line 24
def initialize( value, left, right )
   @value = value
   @left  = left
   @right = right
end

Public Instance Methods

do_dump( depth ) click to toggle source
# File lib/merkletree.rb, line 35
def do_dump( depth )    ## dump (recursive_worker)
  depth.times { print ' ' }
  print "#{depth}:[#{value}] "
  if @left
    print '{'
    puts
    @left.do_dump( depth+1 )
    @right.do_dump( depth+1)  if @right    # note: make right node optional (might be nil/empty)
    depth.times { print ' ' }
    print '}'
  end
  puts
end
dump() click to toggle source

for debugging / testing add pretty printing (dump tree)

# File lib/merkletree.rb, line 33
def dump() do_dump( 0 ); end