utilities 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/utilities.rb +14 -2
  2. data/lib/version.rb +1 -1
  3. metadata +2 -2
@@ -280,9 +280,21 @@ module Utilities
280
280
  end
281
281
 
282
282
  class Hash
283
- # Returns a new hash where {"a"=>1} becomes {:a=>1}
283
+ # Returns a new hash with the results of running block once for every key in self
284
+ def collect_keys
285
+ each_with_object({}){ |(k,v),h| h[yield(k)] = v } if block_given?
286
+ end
287
+ alias_method :map_keys, :collect_keys
288
+
289
+ # Returns a new hash with the results of running block once for every value in self
290
+ def collect_values
291
+ each_with_object({}){ |(k,v),h| h[k] = yield(v) } if block_given?
292
+ end
293
+ alias_method :map_values, :collect_values
294
+
295
+ # Returns a new hash where all keys have been symbolized
284
296
  def symbolize_keys
285
- each_with_object({}){ |(k,v),h| h[k.to_sym] = v }
297
+ collect_keys{ |k| k.to_sym }
286
298
  end
287
299
  end
288
300
 
@@ -1,7 +1,7 @@
1
1
  class Utilities
2
2
  MAJOR = 0
3
3
  MINOR = 0
4
- BUILD = 11
4
+ BUILD = 12
5
5
 
6
6
  VERSION = "#{MAJOR}.#{MINOR}.#{BUILD}"
7
7
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 11
9
- version: 0.0.11
8
+ - 12
9
+ version: 0.0.12
10
10
  platform: ruby
11
11
  authors:
12
12
  - Christian Blais