Sha256: a613a24cac812a45436423a0e7d8a21a00fa98adf2fefe3a7a807c50a6ffb9fa
Contents?: true
Size: 1.49 KB
Versions: 4
Compression:
Stored size: 1.49 KB
Contents
###################################### # WARNING! Highly expiremental code! # ###################################### # = autohash.rb # # == Copyright (c) 2005 Jan Molic # # Ruby License # # This module is free software. You may use, modify, and/or redistribute this # software under the same terms as Ruby. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. # # == Authors and Contributors # # * Jan Molic # Author:: Jan Molic # Copyright:: Copyright (c) 2005 Jan Molic # License:: Ruby License require 'facets/core/hash/self/auto' # = AutoHash # # Like Hash but automatically generates continous subsections. class AutoHash < Hash # Alternate to #new which auto-creates subhash as needed. # # d = AutoHash.new # d.a.b.c = "abc" #=> { :a=>{:b=>{:c=>"abc"}}} # def self.new(*args) auto(*args) end end # # = AutoDictionary # # # # Like Dictionary but automatically generates continues subsections. # # class AutoDictionary < Dictionary # # class << self # # undef_method :auto # undef_method :auto_alpha # # # Alternate to #new which auto-creates sub-dictionaries as needed. # # # # d = Dictionary.auto # # d["a"]["b"]["c"] = "abc" #=> { "a"=>{"b"=>{"c"=>"abc"}}} # # # def new( *args ) # leet = lambda { |hsh, key| hsh[key] = new( &leet ) } # super(*args, &leet) # end # # end # # end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
facets-1.8.0 | work/more/autohash.rb |
facets-1.8.20 | work/more/autohash.rb |
facets-1.8.49 | work/more/autohash.rb |
facets-1.8.8 | work/more/autohash.rb |