Module: Lazybird::Utils::Hash

Defined in:
lib/lazybird/utils.rb

Class Method Summary collapse

Class Method Details

.array_to_hash(keys, values) ⇒ Object



12
13
14
# File 'lib/lazybird/utils.rb', line 12

def self.array_to_hash(keys, values)
  ::Hash[[keys, values].transpose]
end

.compact(hash) ⇒ Object



8
9
10
# File 'lib/lazybird/utils.rb', line 8

def self.compact(hash)
  hash.select { |_, v| v }
end

.find_by_key(hash, key) ⇒ Object



4
5
6
# File 'lib/lazybird/utils.rb', line 4

def self.find_by_key(hash, key)
  hash.select { |k, h| k == key }
end