Class: Axl::Utils::String
- Inherits:
-
Object
- Object
- Axl::Utils::String
- Defined in:
- lib/axl/utils/string.rb
Class Method Summary collapse
Class Method Details
.camelize(str) ⇒ Object
9 10 11 12 |
# File 'lib/axl/utils/string.rb', line 9 def camelize(str) word = str.slice(0,1).capitalize + str.slice(1..-1) word.gsub(/_([a-zA-Z\d])/) { "#{$1.capitalize}" } end |
.constantize(str) ⇒ Object
14 15 16 17 18 |
# File 'lib/axl/utils/string.rb', line 14 def constantize(str) str.split("::").inject(Object) do |namespace, sym| namespace.const_get(self.camelize(sym.to_s), false) end end |
.underscore(str) ⇒ Object
20 21 22 |
# File 'lib/axl/utils/string.rb', line 20 def underscore(str) str.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase end |