./lib/children_hash_deferer.rb in rambling-trie-0.3.2 vs ./lib/children_hash_deferer.rb in rambling-trie-0.3.3
- old
+ new
@@ -1,18 +1,32 @@
module Rambling
+ # Provides some proxy methods to the children's hash for readability.
module ChildrenHashDeferer
+ # Proxies to @children[key]
+ # @param [Symbol] key the key to look for in the children's hash.
+ # @return [TrieNode, nil] the child node with that key or nil.
def [](key)
@children[key]
end
+ # Proxies to @children[key] = value.
+ # @param [Symbol] key the to add or change the value for.
+ # @param [TrieNode] value the node to add to the children's hash.
+ # @return [TrieNode, nil] the child node with that key or nil.
def []=(key, value)
@children[key] = value
end
+ # Proxies to @children.delete(key)
+ # @param [Symbol] key the key to delete in the children's hash.
+ # @return [TrieNode, nil] the child node corresponding to the key just deleted or nil.
def delete(key)
@children.delete(key)
end
+ # Proxies to @children.has_key?(key)
+ # @param [Symbol] key the key to look for in the children's hash.
+ # @return [Boolean] `true` for the keys that exist in the children's hash, false otherwise.
def has_key?(key)
@children.has_key?(key)
end
end
end