triad 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/triad.rb +9 -12
- data/lib/triad/version.rb +1 -1
- 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: 7052c596a5bf5a66ca6319799ac6f88dbc0db106
|
4
|
+
data.tar.gz: 8610fa1b69fbfb99dfc27058a1939628c5c897a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27cb5c5378ab1f88697f746845490fd37387c47adb63e183702f9caafa82573da74f8d419bcb47c05e64a46d9d0418d7708ee33f319216a58bd34990374ff3de
|
7
|
+
data.tar.gz: 50d1516bb0c45f95a4cc9c42588e4d35b632f35410f1bd56afb29b22d4b116e2c9284e3b75f24a05d0d4d4e5f1cde43e8a52da3a04c9fc7ac4f097b035705277
|
data/lib/triad.rb
CHANGED
@@ -8,7 +8,7 @@ class Triad
|
|
8
8
|
class ItemNotPresent < StandardError; end
|
9
9
|
|
10
10
|
# stored as {key => ['Descriptor', value]}
|
11
|
-
def initialize
|
11
|
+
def initialize
|
12
12
|
@storage = ThreadSafe::Hash.new
|
13
13
|
end
|
14
14
|
attr_reader :storage
|
@@ -75,19 +75,16 @@ class Triad
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def with_interest(interest)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
else
|
86
|
-
raise ItemNotPresent.new
|
87
|
-
end
|
78
|
+
position = case
|
79
|
+
when key_exists?(interest) then 0
|
80
|
+
when descriptor_exists?(interest) then 1
|
81
|
+
when value_exists?(interest) then 2
|
82
|
+
else
|
83
|
+
raise ItemNotPresent.new
|
84
|
+
end
|
88
85
|
|
89
86
|
storage.select{|key, array|
|
90
|
-
[key, *array]
|
87
|
+
[key, *array].fetch(position) == interest
|
91
88
|
}.map{|key, array| [key, *array] }
|
92
89
|
end
|
93
90
|
end
|
data/lib/triad/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: triad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Jim Gay'"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_safe
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.4.5
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Manage a collection with 3 data points
|