1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/lib/haml/util.rb
2008-11-22 19:17:06 -08:00

21 lines
394 B
Ruby

module Haml
module Util
class << self; include Haml::Util; end
def to_hash(arr)
arr.compact.inject({}) {|h, (k, v)| h[k] = v; h}
end
def map_keys(hash)
to_hash(hash.map {|k, v| [yield(k), v]})
end
def map_vals(hash)
to_hash(hash.map {|k, v| [k, yield(v)]})
end
def map_hash(hash, &block)
to_hash(hash.map(&block))
end
end
end