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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e7bcbc1535ccb18c49cfd09076c942764bd314f
4
- data.tar.gz: 8417454997da561f492a79e251fa894e4a102578
3
+ metadata.gz: be7671f173a8056d06081dc0b7cc91a6c7971e23
4
+ data.tar.gz: c3be2b5fa86b994894082bdd54a604c41dc44497
5
5
  SHA512:
6
- metadata.gz: b39ed7b7987778b2a5fd6d2d1911f2777abb1d44c248ea121f38de18189ea775f8192e18a8ea0f5e8f9d45e0700724a462764d12824ebcacee1ea6842eb530b0
7
- data.tar.gz: aef50b34442a3fa01a6f743bc655221c064503d7374f01e7a7b890dc5fcc14ef467c8cef04166b87bb6c1f607f65c346eb77ba5b274ab47b722ab793f50226e8
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
- 1)add_hash2_to_hash1 => This adds hash2 values with hash1. Both Hash1 and Hash2
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]}]}
@@ -1,3 +1,3 @@
1
1
  module HashUtil
2
- VERSION = "1.0"
2
+ VERSION = "1.1"
3
3
  end
data/lib/hash_util.rb CHANGED
@@ -63,7 +63,7 @@ module HashUtil
63
63
  end
64
64
 
65
65
  def self.tokenize(str)
66
- str.scan(/[0-9.-]+|\w+/)
66
+ str.scan(/[0-9.e-]+|\w+/)
67
67
  end
68
68
 
69
69
  # extracts all numbers in a hash string
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.0'
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-28 00:00:00.000000000 Z
11
+ date: 2017-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler