fuzzy_ruby 0.0.0 → 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fuzzy_ruby.rb +22 -22
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0fe2ae6cd524a0bfa7a0c3e4653d3f79dfa351a
4
- data.tar.gz: 9d71a16cd1c4ac1051b7dcbc2f585c26bc364bec
3
+ metadata.gz: 6b92009d6bd7c02e372100e053a821dfe37cc233
4
+ data.tar.gz: 3d4b96c499d30f52c4004ecf78f16814fa2a42f7
5
5
  SHA512:
6
- metadata.gz: f0664c599f047b153874de54f2665ecff13dd69982ca768ebd113575e3292ff1d949734b43dd7f974ae17db4079b906f55c354bb2eea5f6f884c83f7a38869a9
7
- data.tar.gz: c793499508e103b9697292af23355248fc2656439ba8502a1779c2f44a380c9adb3e88065a7bb8726f13f57f1756f46d740ce5aba0d3b07817464c199373ffc9
6
+ metadata.gz: 405ca1cb09b2d97a267456bb3dc75c5ddb581cdd75d21c6aaf6aad22ea68aa6a69bdff956db854be81f0923a9891e8cc8edeec59eacccb1218114c39a2672d9e
7
+ data.tar.gz: 63e25bd23e692b8ce164f5ef1ebab0a04cd24ea4d5fa9530f7f06398421816cfe021a5e618cd66bb1100589422c284d316b62a7bc399af18f5d1c499aedbf461
data/lib/fuzzy_ruby.rb CHANGED
@@ -34,31 +34,31 @@ class Fuzzy
34
34
  return ret
35
35
  end
36
36
 
37
- # build the regular expression
38
- def self.build_regexp(string)
39
- regexp = ""
40
- string.each_char do |c|
41
- regexp << "(\w*)#{c}"
42
- end
43
- regexp << "(\w*)"
37
+ # build the regular expression
38
+ def self.build_regexp(string)
39
+ regexp = ""
40
+ string.each_char do |c|
41
+ regexp << "(\w*)#{c}"
44
42
  end
43
+ regexp << "(\w*)"
44
+ end
45
45
 
46
- # recursive function to assign weight to string
47
- # once there is match, removes one character from the reg exp and repeat
48
- def self.assign_weights(index, regexp)
49
- weight = @strings[index] =~ regexp
50
- if weight == nil
51
- return
52
- end
53
- @weights[index] += weight
54
- if !done(index)
55
- @strings[index] = @strings[index][weight+1..@strings[index].length]
56
- assign_weights(index, /#{regexp.source[5..regexp.source.length]}/)
57
- end
46
+ # recursive function to assign weight to string
47
+ # once there is match, removes one character from the reg exp and repeat
48
+ def self.assign_weights(index, regexp)
49
+ weight = @strings[index] =~ regexp
50
+ if weight == nil
51
+ return
58
52
  end
59
-
60
- def self.done(index)
61
- @strings[index] == nil || @weights[index] == -1 ? true : false
53
+ @weights[index] += (weight+1)
54
+ if !done(index)
55
+ @strings[index] = @strings[index][weight+1..@strings[index].length]
56
+ assign_weights(index, /#{regexp.source[5..regexp.source.length]}/)
62
57
  end
58
+ end
59
+
60
+ def self.done(index)
61
+ @strings[index] == nil || @weights[index] == -1 ? true : false
62
+ end
63
63
 
64
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuzzy_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny