hash_util 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -6
- data/lib/hash_util/version.rb +1 -1
- data/lib/hash_util.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be7671f173a8056d06081dc0b7cc91a6c7971e23
|
4
|
+
data.tar.gz: c3be2b5fa86b994894082bdd54a604c41dc44497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59ecf19418884204efd92ee9fcd703e32d3555642bb5eca36c11b03fda866d90ed24cb38d500441b9c89bd36165f75c544b2c3a1f4b64c28e81a57579960d87f
|
7
|
+
data.tar.gz: 4e4449bd0b32790b85490b7db7893909feab50e6d0f744837bef19142ba4b7330a9741727c70bb7a15dfb1e32b60e3784696923b766e7bf9f9606fd153308a34
|
data/README.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
# HashUtil
|
2
2
|
|
3
3
|
Hash utility methods.
|
4
|
-
|
4
|
+
|
5
|
+
1) add_hash2_to_hash1 => This adds hash2 values with hash1. Both Hash1 and Hash2
|
5
6
|
should be of same structure
|
6
7
|
|
7
|
-
2)zero => This sets all values of a hash to 0
|
8
|
+
2) zero => This sets all values of a hash to 0
|
9
|
+
|
10
|
+
3) merge => Overrides hash1 values with hash2 values
|
11
|
+
|
12
|
+
4) tokenize => tokenizes a hash and returns a flat array
|
13
|
+
|
14
|
+
5) extract_numbers_hash => extracts numbers from a hash
|
15
|
+
|
8
16
|
|
9
17
|
## Installation
|
10
18
|
|
@@ -24,7 +32,7 @@ Or install it yourself as:
|
|
24
32
|
|
25
33
|
## Usage
|
26
34
|
|
27
|
-
(1)add_hash2_to_hash1
|
35
|
+
(1)add_hash2_to_hash1
|
28
36
|
```ruby
|
29
37
|
hash1 = {a:1,b:2,c:[1,2],d:{a:1}}
|
30
38
|
hash2 = {a:3,b:3,c:[3,2],d:{a:10}}
|
@@ -36,7 +44,6 @@ hash1 = {a:1,b:2,c:[1,2],d:{a:1}}
|
|
36
44
|
HashUtil.zero(hash1) #{a:0,b:0,c:[0,0],d:{a:0}}
|
37
45
|
```
|
38
46
|
(3) merge
|
39
|
-
0verrides hash1 values with hash2 values.
|
40
47
|
```ruby
|
41
48
|
str1 = %{
|
42
49
|
{ "OccExp": [ -0.0004, 0.09600, 0.0000, -0.0204, 0.09 ,"abc":{"a":1,"b":0,"c":[0,1,2]} ],
|
@@ -51,7 +58,6 @@ HashUtil.zero(hash1) #{a:0,b:0,c:[0,0],d:{a:0}}
|
|
51
58
|
str1 = HashUtil.merge(str1,str2) # values in str1 == str2
|
52
59
|
```
|
53
60
|
(4) tokenize
|
54
|
-
tokenizes a hash and returns a flat array
|
55
61
|
```ruby
|
56
62
|
str2 = %{
|
57
63
|
{ "OccExp": [ 0.0250000004, 0.0199999996, "abc":{"a":1,"b":0,"c":[0,1,2]}]}
|
@@ -59,7 +65,6 @@ tokenizes a hash and returns a flat array
|
|
59
65
|
HashUtil.extract_numbers_hash(str2) #[ 0.0250000004, 0.0199999996,1,0,0,1,2]
|
60
66
|
```
|
61
67
|
(5) extract_numbers_hash
|
62
|
-
extracts numbers from a hash
|
63
68
|
```ruby
|
64
69
|
str2 = %{
|
65
70
|
{ "OccExp": [ 0.0250000004, 0.0199999996, "abc":{"a":1,"b":0,"c":[0,1,2]}]}
|
data/lib/hash_util/version.rb
CHANGED
data/lib/hash_util.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dinesh.theetla@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|