diviner 0.1.4 → 0.2.0
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/VERSION +1 -1
- data/diviner.gemspec +2 -2
- data/lib/deviner/match.rb +7 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6be5f55fb880e569f6dfc5689900da4bbe45ba41
|
4
|
+
data.tar.gz: 5cb2a6530009f792a5ae4aeacfc56aace3094975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8b5e4425700763d7e1902b1c46df05c90b94d8fc31615c606b1ba5a0fda6686a027b4eb0a16c43ada4cd88fa00d8310569e5b67c11f00d804ba070f410a91a0
|
7
|
+
data.tar.gz: f540da2126116b846188a4d3d77211a505482623e5863093c1bb6720cb7ecbd798264dca19fcad689522dd7ad47d9e43b34756e42484b5be046498f0aa6d70e0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/diviner.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: diviner 0.
|
5
|
+
# stub: diviner 0.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "diviner"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
data/lib/deviner/match.rb
CHANGED
@@ -47,6 +47,8 @@ module Deviner
|
|
47
47
|
clear_cache
|
48
48
|
end
|
49
49
|
|
50
|
+
|
51
|
+
# Return nil if no matches found
|
50
52
|
def match(categories)
|
51
53
|
result = []
|
52
54
|
for category in categories
|
@@ -56,13 +58,14 @@ module Deviner
|
|
56
58
|
|
57
59
|
highest_value = result.map{|x| x[:value]}.sort.last
|
58
60
|
selected_category = nil
|
59
|
-
|
60
|
-
|
61
|
-
|
61
|
+
if highest_value > 0
|
62
|
+
result.each do |hash|
|
63
|
+
if hash[:value] == highest_value
|
64
|
+
selected_category = hash[:category]
|
65
|
+
end
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
65
|
-
result = result.reject{ |x| x[:value] != highest_value}
|
66
69
|
return selected_category
|
67
70
|
|
68
71
|
end
|