hesh 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/lib/hesh.rb +11 -0
- data/lib/hesh/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 991c9c276b3e5437074c7b25be12c1eb74851148d7223adcb0d7224d022cb302
|
4
|
+
data.tar.gz: eab09ad0a69764fbd8222e7a6e933442a7ba7dee514a20fc26b108cce05ba40a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9da29f51a4dbf326e5dbbb40b65749bbf509af484630c9b30445a4b805403ceafd102611d0db8e209bdac170cddf9539eefbf5fda738ed919b3c6d0c04b082b
|
7
|
+
data.tar.gz: 516ab4b53d42ecf349696e49bfdb01ac893d247210260f8e9c535c546488c78a6a69601ebc25a4e12c019087199d193890df6baeeecd180a6110c179627168a3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,6 +7,9 @@ Hesh makes Hashes. That's it for now. I may come up with something more clever l
|
|
7
7
|
Run down of the functions:
|
8
8
|
|
9
9
|
```ruby
|
10
|
+
# Makes a new Hash with a function used to determine the default value
|
11
|
+
Hesh.of { [] } # == Hash.new { |h,k| h[k] = fn.call(h, k) }
|
12
|
+
|
10
13
|
# Makes a new Hash with default values of a new array
|
11
14
|
Hesh.of_array # == Hash.new { |h,k| h[k] = [] }
|
12
15
|
|
data/lib/hesh.rb
CHANGED
@@ -13,6 +13,17 @@ class Hesh
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class << self
|
16
|
+
# Creates a Hash of something, I'm not sure what, you tell me!
|
17
|
+
#
|
18
|
+
# @param &fn [Proc]
|
19
|
+
# Function for default value of the hash, yielding the hash and
|
20
|
+
# key if ya need them
|
21
|
+
#
|
22
|
+
# @return [Hash[Any, Any]]
|
23
|
+
def of(&fn)
|
24
|
+
Hash.new { |h, k| h[k] = fn.call(h, k) }
|
25
|
+
end
|
26
|
+
|
16
27
|
# Creates a Hash of arrays
|
17
28
|
#
|
18
29
|
# @return [Hash[Any, Array]]
|
data/lib/hesh/version.rb
CHANGED