triad 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/triad.rb +9 -12
  3. data/lib/triad/version.rb +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c2803e0e4b1a381b1bf4b0dde05a3e75f459404
4
- data.tar.gz: 5bf33b48f87d5a03eb3579181cc6fa3f3bf0c483
3
+ metadata.gz: 7052c596a5bf5a66ca6319799ac6f88dbc0db106
4
+ data.tar.gz: 8610fa1b69fbfb99dfc27058a1939628c5c897a5
5
5
  SHA512:
6
- metadata.gz: bd4f351d5d91f0133667918cade75192fbf1f46e45c33e78090d7d4a45a80a62a496eb1a9a17f6e1c46bac5a2afb85b8b37be02f18751b68f6cb3ef71e8b8de5
7
- data.tar.gz: 3ad7881dc4182e9a8ecd7b16b5d5f6cfbadd9cbe7bf717149579f3b0dc0a703878f5a2381bca2c9dd6b24e90dfb7e8cf97b49d0a3f30fbd11343c72ff0a6c364
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(*args)
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
- index = case
79
- when key_exists?(interest)
80
- 0
81
- when descriptor_exists?(interest)
82
- 1
83
- when value_exists?(interest)
84
- 2
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][index] == interest
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
@@ -1,3 +1,3 @@
1
1
  class Triad
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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: 2014-05-08 00:00:00.000000000 Z
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.2.0
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