What is this Hash-like/Tree-like Construct Called?
- by viatropos
I want to create a "Config" class that acts somewhere between a hash and a tree.  It's just for storing global values, which can have a context.
Here's how I use it:
Config.get("root.parent.child_b") #=> "value"
Here's what the class might look like:
class Construct
  def get(path)
    # split path by "."
    # search tree for nodes
  end
  def set(key, value)
    # split path by "."
    # create tree node if necessary
    # set tree value
  end
  def tree
    {
      :root => {
        :parent => {
          :child_a => "value",
          :child_b => "another value"
        },
        :another_parent => {
          :something => {
            :nesting => "goes on and on"
          }
        }
      }
    }
  end
end
Is there a name for this kind of thing, somewhere between Hash and Tree (not a Computer Science major)?  Basically a hash-like interface to a tree.