Sha256: 84af34e7d884aaf582d08c1de8061995d22c4d7ac8e1b911969c3d57704e0002

Contents?: true

Size: 352 Bytes

Versions: 16

Compression:

Stored size: 352 Bytes

Contents

class Hash

  # Iterate over hash updating just the keys.
  #
  #   h = {:a=>1, :b=>2}
  #   h.update_keys{ |k| "#{k}!" }
  #   h  #=> { "a!"=>1, "b!"=>2 }
  #
  # CREDIT: Trans

  def update_keys #:yield:
    if block_given?
      keys.each { |old_key| store(yield(old_key), delete(old_key)) }
    else
      to_enum(:update_keys)
    end
  end

end

Version data entries

16 entries across 15 versions & 1 rubygems

Version Path
facets-2.9.2 src/core/facets/hash/update_keys.rb
facets-2.9.2 lib/core/facets/hash/update_keys.rb
facets-2.9.1 lib/core/facets/hash/update_keys.rb
facets-2.9.0 lib/core/facets/hash/update_keys.rb
facets-2.9.0.pre.2 lib/core/facets/hash/update_keys.rb
facets-2.9.0.pre.1 lib/core/facets/hash/update_keys.rb
facets-2.8.4 lib/core/facets/hash/update_keys.rb
facets-2.8.3 lib/core/facets/hash/update_keys.rb
facets-2.8.2 lib/core/facets/hash/update_keys.rb
facets-2.8.1 lib/core/facets/hash/update_keys.rb
facets-2.8.0 lib/core/facets/hash/update_keys.rb
facets-2.7.0 lib/core/facets/hash/update_keys.rb
facets-2.6.0 lib/core/facets/hash/update_keys.rb
facets-2.5.1 lib/core/facets/hash/update_keys.rb
facets-2.5.0 lib/core/facets/hash/update_keys.rb
facets-2.5.2 lib/core/facets/hash/update_keys.rb