Method: SassC::Util#map_keys

Defined in:
lib/sassc/util.rb

#map_keys(hash) {|key| ... } ⇒ Hash

Maps the keys in a hash according to a block.

Examples:

map_keys({:foo => "bar", :baz => "bang"}) {|k| k.to_s}
  #=> {"foo" => "bar", "baz" => "bang"}

Parameters:

  • hash (Hash)

    The hash to map

Yields:

  • (key)

    A block in which the keys are transformed

Yield Parameters:

  • key (Object)

    The key that should be mapped

Yield Returns:

  • (Object)

    The new value for the key

Returns:

  • (Hash)

    The mapped hash

See Also:

  • #map_vals
  • #map_hash


38
39
40
# File 'lib/sassc/util.rb', line 38

def map_keys(hash)
  map_hash(hash) {|k, v| [yield(k), v]}
end