Module: Hash::Extras

Included in:
Hash
Defined in:
lib/vex/base/hash/extras.rb

Defined Under Namespace

Modules: ClassMethods, Etest

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



2
3
4
# File 'lib/vex/base/hash/extras.rb', line 2

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#delete_all(*args) ⇒ Object



20
21
22
23
24
# File 'lib/vex/base/hash/extras.rb', line 20

def delete_all(*args)
  args.inject([]) do |array, arg|
    array << delete(arg)
  end
end

#hmap(&block) ⇒ Object

compare



13
14
15
16
17
18
# File 'lib/vex/base/hash/extras.rb', line 13

def hmap(&block)
  self.inject({}) { |h, i|
    h.update i[0] => yield(i[0], i[1])
    h
  }
end

#select_entries(*args) ⇒ Object



26
27
28
29
30
# File 'lib/vex/base/hash/extras.rb', line 26

def select_entries(*args)
  args.inject([]) do |array, arg|
    array << self[arg]
  end
end