lib/middlemac/trie-extension.rb
# Recursive implementation function for `to_h`.
Recursive implementation function for `to_h`.
Recursive implementation function for ` to_h ` .
def to_h_impl(root)
    result = {}
    ('a'..'z').each do |i|
      if root.walk(i)
        result[i] = {} unless result.key?(i)
        if root.walk(i).terminal?
          result[i]['$'] = root.walk(i).value
        end
        unless root.walk(i).leaf?
          result[i]['_'] = self.to_h_impl(root.walk(i))
        end
      end
    end
    result
  end
def to_h_impl ( root ) result = { } ( 'a' .. 'z' ) . each do | i | if root . walk ( i ) result [ i ] = { } unless result . key? ( i ) if root . walk ( i ) . terminal? result [ i ] [ '$' ] = root . walk ( i ) . value end unless root . walk ( i ) . leaf? result [ i ] [ '_' ] = self . to_h_impl ( root . walk ( i ) ) end end end result end
Recursive implementation function for `to_h`.
Recursive implementation function for ` to_h ` .
root
<not_specific>