nice_hash 1.11.0 → 1.11.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
  SHA256:
3
- metadata.gz: 4f9d38f369371f390a0130578927581aa8a221d893a54ebb333b97915cbf09b1
4
- data.tar.gz: 93010cd4b125ab1aec51e31d99337bed6ea16b63f91a55346bdf6a405c28336d
3
+ metadata.gz: 4be1a70536463825b897bd3909ce45af63682d24feb90bf2211fde12eefe6a0b
4
+ data.tar.gz: a2b950c140645c84df85f10983b391e2e27dc5a9d47b1d52bd0d376e40a112a4
5
5
  SHA512:
6
- metadata.gz: 803dc5e30404787f0029a95d3f3ddf7305d8c486dbfb77e85f6881f397c30247ae203d5b61384b6046ea3aa0ea4ecd07c230351f7c206cdcff3c82962c414fdb
7
- data.tar.gz: e585a261a7c73f8360c31cf56141b88091105c1f2ccf00cfb427fe9b60a3ab60b46304950f227664b619c17216af73ee0d0e4b79765671af40fd79b102560f72
6
+ metadata.gz: 8e873b902bcd8d61a8eb7fad6fd4546ca31e46e69e1c84d41920e2383c525dc711dc9dca37e40cc3596ca3e64c5d09e6c64237ac76fe49a1490b89c7ea5afe30
7
+ data.tar.gz: ca7cc5d760a262050c2804e7ca80ca04120fa3c9602acaf93848edb5b0770bbece7c2f405772a2537c2cfe3eb64f2211674d4fafd9d3b3eac3f56885a17d836e
@@ -21,9 +21,10 @@ class String
21
21
  # 1 value with key or an array of keys
22
22
  # In case the key supplied doesn't exist in the hash then it will be returned nil for that one
23
23
  # output:
24
- # if keys given: a hash of (keys, values) or the value, if the key is found more than once in the json string, then it will be return a hash op arrays.
24
+ # if keys given: a hash of (keys, values) or the value, if the key is found more than once in the json string, then it will be return a hash of arrays.
25
25
  # if no keys given: the json string as a ruby structure.
26
26
  # if no json string or wrong json string, an empty hash.
27
+ # if one key supplied and doesn't exist on the json string then an empty hash
27
28
  ###########################################################################
28
29
  def json(*keys)
29
30
  require "json"
@@ -36,10 +37,13 @@ class String
36
37
  else
37
38
  {}
38
39
  end
39
-
40
40
  if result_tmp.size == 1
41
41
  result = if result_tmp.values.is_a?(Array) && (result_tmp.values.size == 1)
42
- result_tmp.values[0]
42
+ if result_tmp.values[0].nil?
43
+ {}
44
+ else
45
+ result_tmp.values[0]
46
+ end
43
47
  else
44
48
  result_tmp.values
45
49
  end
data/lib/nice_hash.rb CHANGED
@@ -618,7 +618,7 @@ class NiceHash
618
618
 
619
619
  ##################################################
620
620
  # Get values from the Hash structure (array of Hashes allowed)
621
- # In case the key supplied doesn't exist in the hash then it will be return nil for that one
621
+ # In case the key supplied doesn't exist in the hash then it will be returned nil for that one
622
622
  # input:
623
623
  # hashv: a simple hash or a hash containing arrays. Example:
624
624
  # example={"id"=>344,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nice_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-19 00:00:00.000000000 Z
11
+ date: 2019-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string_pattern