Sha256: 76737709f55b4b2bc5439ae7e3b15f6efb7e9a4ff98d52aa9cc7194a06647dfd

Contents?: true

Size: 239 Bytes

Versions: 9

Compression:

Stored size: 239 Bytes

Contents

class Hash
  def subset keys = nil, &block
    h = {}
    if keys
      self.each do |k, v|
        h[k] = v if keys.include? k
      end
    else
      self.each do |k, v|
        h[k] = v if block.call k
      end
    end
    h
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
ruby_ext-0.4.11 lib/ruby_ext/hash.rb
ruby_ext-0.4.10 lib/ruby_ext/hash.rb
ruby_ext-0.4.9 lib/ruby_ext/hash.rb
ruby_ext-0.4.7 lib/ruby_ext/hash.rb
ruby_ext-0.4.6 lib/ruby_ext/hash.rb
ruby-ext-0.4.6 lib/ruby_ext/hash.rb
ruby-ext-0.4.4 lib/ruby_ext/hash.rb
ruby-ext-0.4.3 lib/ruby_ext/hash.rb
ruby-ext-0.4.2 lib/ruby_ext/hash.rb