Sha256: 6ea060472ec86bf7e28f6d8916859f6affa701ee38715b3f98e193ef9f20e3a3

Contents?: true

Size: 720 Bytes

Versions: 19

Compression:

Stored size: 720 Bytes

Contents

#!/usr/local/bin/ruby -w
# A template for new files in the project; of no interest to end users.  An
# error will be raised if you +require+ it.
#--
# :enddoc:
#
# == extensions/XXX.rb
#
# Adds methods to the builtin XXX class. 
#

raise "Do not load this file!"

require "extensions/_base"

#
# * Enumerable#build_hash
#
ExtensionsProject.implement(Enumerable, :build_hash) do
  module Enumerable
    #
    # Like #map/#collect, but it generates a Hash.
    #
    #   [1,5,11].build_hash { |x| [x, x**2] }
    #      => { 1 => 2, 5 => 25, 11 => 121 }
    #
    def build_hash
      result = {}
      self.each do |elt|
        key, value = yield elt
        result[key] = value
      end
      result
    end
  end
end

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
extensions-0.5.0 lib/extensions/_template.rb
extensions-0.6.0 lib/extensions/_template.rb
glue-0.15.0 vendor/extensions/_template.rb
glue-0.14.0 vendor/extensions/_template.rb
glue-0.16.0 vendor/extensions/_template.rb
glue-0.17.0 vendor/extensions/_template.rb
nitro-0.11.0 vendor/extensions/_template.rb
nitro-0.10.0 vendor/extensions/_template.rb
nitro-0.12.0 vendor/extensions/_template.rb
nitro-0.13.0 vendor/extensions/_template.rb
nitro-0.9.5 vendor/extensions/_template.rb
nitro-0.8.0 vendor/extensions/_template.rb
nitro-0.9.3 vendor/extensions/_template.rb
og-0.11.0 vendor/extensions/_template.rb
og-0.10.0 vendor/extensions/_template.rb
og-0.12.0 vendor/extensions/_template.rb
og-0.8.0 vendor/extensions/_template.rb
og-0.9.5 vendor/extensions/_template.rb
og-0.9.3 vendor/extensions/_template.rb