A
ara.t.howard
NAME
map.rb
SYNOPSIS
the ruby container you've always wanted: a string/symbol indifferent
ordered
hash that works in all rubies
INSTALL
gem install map
URI
http://github.com/ahoward/map
DESCRIPTION
# maps are ordered. constructing them in an ordered fashion builds
them that
# way
#
m = Map[:k, :v, :key, :val]
m = Mapk, :v, :key, :val)
m = Map[[:k, :v], [:key, :val]]
m = Map[{:k => :v, :key => :val}]
m = Map.new
m[:a] = 0
m[:b] = 1
m[:c] = 2
p m.keys #=> ['a','b','c'] ### always ordered!
p m.values #=> [0,1,2] ### always ordered!
# maps don't care between symbol and string keys
#
p m[:a] #=> 0
p m["a"] #=> 0
# many functions operate in a way one would expect from an ordered
container
#
m.updatek2 => :v2)
m.updatek2, :v2)
# maps keep mapiness for even deep operations
#
m.update :nested => {:hashes => {:are => :converted}}
# maps can give back clever little struct objects
#
m = Mapfoo => {:bar => 42})
s = m.struct
p s.foo.bar #=> 42
USAGE
test/map_test.rb
map.rb
SYNOPSIS
the ruby container you've always wanted: a string/symbol indifferent
ordered
hash that works in all rubies
INSTALL
gem install map
URI
http://github.com/ahoward/map
DESCRIPTION
# maps are ordered. constructing them in an ordered fashion builds
them that
# way
#
m = Map[:k, :v, :key, :val]
m = Mapk, :v, :key, :val)
m = Map[[:k, :v], [:key, :val]]
m = Map[{:k => :v, :key => :val}]
m = Map.new
m[:a] = 0
m[:b] = 1
m[:c] = 2
p m.keys #=> ['a','b','c'] ### always ordered!
p m.values #=> [0,1,2] ### always ordered!
# maps don't care between symbol and string keys
#
p m[:a] #=> 0
p m["a"] #=> 0
# many functions operate in a way one would expect from an ordered
container
#
m.updatek2 => :v2)
m.updatek2, :v2)
# maps keep mapiness for even deep operations
#
m.update :nested => {:hashes => {:are => :converted}}
# maps can give back clever little struct objects
#
m = Mapfoo => {:bar => 42})
s = m.struct
p s.foo.bar #=> 42
USAGE
test/map_test.rb