datastruct 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/lib/datastruct.rb +17 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d87f5724b107fd84295b0128e69c50902894204c
|
4
|
+
data.tar.gz: bec01b7ffc717fde3401eefe4890f7278e484d78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e449b0ff8418176f11d5699e13de2a9c6b34facf2abb012b4ec44b697657d763939703588e91af9431a4c44d2759c17d56e650943543cdf6257e162b3575403
|
7
|
+
data.tar.gz: f68a909dba3b9f79a05e70016c1793534f7798a612b38ce6b25c69f24b23d8c41fe823645bf5849cc36a5ea48b216a8c613ffa53c980870dabef7dff82ee2b29
|
data/lib/datastruct.rb
CHANGED
@@ -11,7 +11,7 @@ def DataStruct(*props, &block)
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class DataStruct
|
14
|
-
VERSION = "0.0.
|
14
|
+
VERSION = "0.0.6"
|
15
15
|
|
16
16
|
##
|
17
17
|
# Makes sure +@data+ is set before +initialize+ is called
|
@@ -174,12 +174,22 @@ class DataStruct
|
|
174
174
|
#
|
175
175
|
# @return [Hash]
|
176
176
|
#
|
177
|
-
def to_hash(string_keys: false)
|
178
|
-
if string_keys
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
177
|
+
def to_hash(string_keys: false, deep: false)
|
178
|
+
return @data.dup if not string_keys and not deep
|
179
|
+
|
180
|
+
out = {}
|
181
|
+
|
182
|
+
@data.each_pair { |key, value|
|
183
|
+
key = key.to_s if string_keys
|
184
|
+
|
185
|
+
if deep and value.is_a? DataStruct
|
186
|
+
value = value.to_hash(string_keys: string_keys, deep: true)
|
187
|
+
end
|
188
|
+
|
189
|
+
out[key] = value
|
190
|
+
}
|
191
|
+
|
192
|
+
return out
|
183
193
|
end
|
184
194
|
|
185
195
|
alias_method :to_h, :to_hash
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datastruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Sandven
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -120,7 +120,7 @@ files:
|
|
120
120
|
- lib/datastruct.rb
|
121
121
|
homepage: https://github.com/Hubro/Datastruct
|
122
122
|
licenses:
|
123
|
-
- GPL
|
123
|
+
- GPL-3.0
|
124
124
|
metadata: {}
|
125
125
|
post_install_message:
|
126
126
|
rdoc_options: []
|