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.
Files changed (3) hide show
  1. data/lib/fk_str.rb +20 -0
  2. data/test/test_fk_str.rb +9 -0
  3. 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
@@ -125,6 +125,15 @@ class FkStrTest < Test::Unit::TestCase
125
125
 
126
126
  end
127
127
 
128
+ def test_downcase
129
+
130
+ assert_equal(
131
+ 'açúcar',
132
+ FkStr.downcase('AÇÚCAR')
133
+ )
134
+
135
+ end
136
+
128
137
  def test_upcasewords
129
138
 
130
139
  assert_equal(
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.1
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-03-13 00:00:00.000000000 Z
12
+ date: 2012-12-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: String manipulation.
15
15
  email: guilhermebaptistasilva@gmail.com