multi_hash_iterator 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c32d73415e08880797327bbd129fd53dcef6e252
4
- data.tar.gz: 2ee116a6205b0f3e9932389d006d9b2d6c54a2df
3
+ metadata.gz: 0240a2cb6a7b4e7dfd4ad1ff2ce0e68becb1b8d1
4
+ data.tar.gz: 195e9ff6e08e85ea4e37937b5d9ab206affd3a94
5
5
  SHA512:
6
- metadata.gz: fc5597a65a39ddf1e9849c3c31a17f34849c55d41676e9f4f583357cfd5ca8d36b41b110f287e444183295c8e415d0c8379a2d437209838a47ca164baf937417
7
- data.tar.gz: 6acd3756c7249d81d9d574db38660d1dbd3bd04669ec57b2bc37e2097a10d0b02da29d3164c2e9032dde533211505930f383dfca8ab00931b53bd845dd43b280
6
+ metadata.gz: b2747816ff666c20613a741ae3a4a1e8ded781cb5db45c833ee966539990caf8316c48f1abf9f46c0c92a6d23558a241bcb383ee47a272307524bc899168b8c9
7
+ data.tar.gz: c880287be29af92a506e77d1d0e2322cf09c421ae49bf8df6b9135a7a09b4612d77900b8750617191aec2c45b83dd7fefa62275fa90bd4b9a69215543e0ef8a8
data/README.markdown CHANGED
@@ -22,3 +22,8 @@ will be used. See Example.
22
22
  # 2nd iteration: k = c, v = [11, nil, 10]
23
23
  # 3rd iteration: k = b, v = [nil, 2, nil]
24
24
  end
25
+
26
+ Or direct access
27
+
28
+ mh = MultiHash.new(h1, h2, h3)
29
+ mh[:c] # => [11, nil, 10]
@@ -37,6 +37,11 @@ class MultiHash
37
37
  end
38
38
  end
39
39
 
40
+
41
+ def [] key
42
+ @memo[key] ||= @hashes.collect { |h| h[key] }
43
+ end
44
+
40
45
  end
41
46
 
42
47
 
@@ -2,7 +2,7 @@ require './lib/multi_hash_iterator'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "multi_hash_iterator"
5
- s.version = "0.1.2"
5
+ s.version = "0.1.3"
6
6
  s.authors = ["Albert Tedja"]
7
7
  s.email = "nicho_tedja@yahoo.com"
8
8
  s.homepage = "https://github.com/atedja/multi_hash_iterator"
@@ -143,4 +143,15 @@ class TestMultiHashIterator < Minitest::Test
143
143
  end
144
144
 
145
145
 
146
+ def test_direct_access
147
+ h1 = { name: "John", last: "Travolta" }
148
+ h2 = { name: "Harrison", last: "Ford" }
149
+ h3 = { name: "Jane", last: "Fonda" }
150
+ h4 = { a: "Jane", last: 10.3 }
151
+ mh = MultiHash.new(h1, h2, h3, h4)
152
+ assert_equal ["John", "Harrison", "Jane", nil], mh[:name]
153
+ assert_equal ["Travolta", "Ford", "Fonda", 10.3], mh[:last]
154
+ end
155
+
156
+
146
157
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_hash_iterator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Tedja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-13 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -85,9 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.4.5
88
+ rubygems_version: 2.4.6
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: Iterate through multiple hashmaps at once
92
92
  test_files: []
93
- has_rdoc: