classify 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/classify.gemspec +1 -1
- data/lib/classify.rb +4 -3
- metadata +1 -1
data/classify.gemspec
CHANGED
data/lib/classify.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Classify
|
2
2
|
def self.it!(string)
|
3
|
-
|
4
|
-
|
3
|
+
cf = Classify.new
|
4
|
+
cf.try_converting(cf.camelize(string))
|
5
5
|
end
|
6
6
|
|
7
7
|
def try_converting(string)
|
@@ -13,6 +13,7 @@ class Classify
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def camelize(string)
|
16
|
-
|
16
|
+
raise ArgumentError, "Wrong argument #{string.inspect}" if not string.class == String or string.match(/(^\_)|(\_$)|([^a-z0-9\_])/i)
|
17
|
+
string.gsub(/^(.{1})|\_.{1}/) { |s| s.gsub(/[^a-z0-9]+/i, '').capitalize }
|
17
18
|
end
|
18
19
|
end
|