123456789_123456789_123456789_123456789_123456789_

Class: DEBUGGER__::AbbrevCommand::TrieNode

Relationships & Source Files
Inherits: Object
Defined in: lib/debug/abbrev_command.rb

Class Method Summary

Instance Method Summary

Constructor Details

.newTrieNode

[ GitHub ]

  
# File 'lib/debug/abbrev_command.rb', line 5

def initialize
  @children = {}
  @types = {} # set
end

Instance Method Details

#[](c)

[ GitHub ]

  
# File 'lib/debug/abbrev_command.rb', line 15

def [](c)
  @children[c]
end

#add_type(type)

[ GitHub ]

  
# File 'lib/debug/abbrev_command.rb', line 19

def add_type type
  @types[type] = true
  self
end

#append(c, type)

[ GitHub ]

  
# File 'lib/debug/abbrev_command.rb', line 10

def append c, type
  trie = (@children[c] ||= TrieNode.new)
  trie.add_type type
end

#candidates

[ GitHub ]

  
# File 'lib/debug/abbrev_command.rb', line 36

def candidates
  @children.map{|c, n|
    ss = n.candidates
    ss.empty? ? c :
    ss.map{|s|
      c+s
    }
  }.flatten
end

#type

[ GitHub ]

  
# File 'lib/debug/abbrev_command.rb', line 28

def type
  if @types.size == 1
    @types.keys.first
  else
    nil
  end
end

#types

[ GitHub ]

  
# File 'lib/debug/abbrev_command.rb', line 24

def types
  @types.keys
end