Class: Melisa::IntTrie

Inherits:
BytesTrie show all
Defined in:
lib/melisa/int_trie.rb

Instance Attribute Summary

Attributes inherited from Trie

#trie

Instance Method Summary collapse

Methods inherited from BytesTrie

#add_many, #each, #get, #get_all, #include?, #initialize, #set

Methods inherited from Trie

#add, #add_many, #agent, #build, #build_if_necessary, #built?, #each, #get_id, #get_key, #get_weight, #has_keys?, #include?, #initialize, #keys, #load, #save, #search, #size

Methods included from BaseConfigFlags

#binary_flag, #config_flags, #lookup_cache_size, #valid_node_order, #valid_num_tries

Constructor Details

This class inherits a constructor from Melisa::BytesTrie

Instance Method Details

#sum(prefix = '') ⇒ Object



3
4
5
6
7
# File 'lib/melisa/int_trie.rb', line 3

def sum(prefix='')
  search(prefix).each.inject(0) do |total,str|
    total + unserialize_value(str.split(@sep).last)
  end
end