mh_extensions 0.1.5.5 → 0.1.5.6
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.
- data/CHANGELOG.rdoc +2 -0
- data/Rakefile +1 -1
- data/lib/string.rb +13 -2
- data/mh_extensions.gemspec +1 -1
- metadata +1 -1
data/CHANGELOG.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'rake'
|
4
4
|
require 'echoe'
|
5
5
|
|
6
|
-
Echoe.new('mh_extensions', '0.1.5.
|
6
|
+
Echoe.new('mh_extensions', '0.1.5.6') do |p|
|
7
7
|
p.description = "Package of usefull ruby basic classes (and not only) extensions"
|
8
8
|
p.url = "https://github.com/mensfeld/MH-Extensions"
|
9
9
|
p.author = "Maciej Mensfeld"
|
data/lib/string.rb
CHANGED
@@ -95,8 +95,7 @@ class String
|
|
95
95
|
# Examples:
|
96
96
|
# "Fixnum".to_class #=> Fixnum
|
97
97
|
# "Something".to_class #=> nil
|
98
|
-
|
99
|
-
def to_class
|
98
|
+
def to_class
|
100
99
|
chain = self.split "::"
|
101
100
|
klass = Kernel
|
102
101
|
chain.each do |klass_string|
|
@@ -106,6 +105,18 @@ class String
|
|
106
105
|
rescue NameError
|
107
106
|
nil
|
108
107
|
end
|
108
|
+
|
109
|
+
def camelize(first_letter_in_uppercase = true)
|
110
|
+
if first_letter_in_uppercase
|
111
|
+
self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
112
|
+
else
|
113
|
+
self.to_s[0].chr.downcase + camelize(self)[1..-1]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def camelize!(first_letter_in_uppercase = true)
|
118
|
+
self.replace self.camelize(first_letter_in_uppercase)
|
119
|
+
self
|
109
120
|
end
|
110
121
|
|
111
122
|
end
|
data/mh_extensions.gemspec
CHANGED