Sha256: 39280fd30068540c2c84edb2097cacdcd9005651a417d8f7c8ddcdeaddf9e1b2

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

module Rambling
  module Trie
    # 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 [Node, 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 [Node] value the node to add to the children's hash.
      # @return [Node, 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 [Node, 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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rambling-trie-0.5.0 lib/rambling/trie/children_hash_deferer.rb
rambling-trie-0.4.2 lib/rambling/trie/children_hash_deferer.rb
rambling-trie-0.4.1 lib/rambling-trie/children_hash_deferer.rb