fk_str 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fk_str.rb +20 -0
- data/test/test_fk_str.rb +9 -0
- metadata +2 -2
data/lib/fk_str.rb
CHANGED
@@ -76,6 +76,26 @@ module FkStr
|
|
76
76
|
|
77
77
|
end
|
78
78
|
|
79
|
+
def self.downcase w
|
80
|
+
|
81
|
+
return w if w.to_s == ''
|
82
|
+
|
83
|
+
# Cria uma Array apenas com os caracteres necessários por questões de performance.
|
84
|
+
letters = []
|
85
|
+
clean_word = self.remove_accents(w).downcase.gsub(/[^a-z]/, '')
|
86
|
+
clean_word.split('').uniq.each { |lt| @@letters_by_letter[lt].each { |l| letters << l } }
|
87
|
+
|
88
|
+
letters.each do |l|
|
89
|
+
|
90
|
+
# Transforma tudo em minúsculo.
|
91
|
+
w = w.gsub l[1], l[0]
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
return w
|
96
|
+
|
97
|
+
end
|
98
|
+
|
79
99
|
# 35 seconds
|
80
100
|
# 18 seconds
|
81
101
|
# 16 seconds
|
data/test/test_fk_str.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fk_str
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: String manipulation.
|
15
15
|
email: guilhermebaptistasilva@gmail.com
|