Class: Aviator::StrUtil
- Inherits:
-
Object
- Object
- Aviator::StrUtil
- Defined in:
- lib/aviator/core/utils/string.rb
Class Method Summary collapse
Class Method Details
.camelize(str) ⇒ Object
7 8 9 10 |
# File 'lib/aviator/core/utils/string.rb', line 7 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
12 13 14 15 16 |
# File 'lib/aviator/core/utils/string.rb', line 12 def constantize(str) str.split("::").inject(Object) do |namespace, sym| namespace.const_get(self.camelize(sym.to_s), false) end end |
.underscore(str) ⇒ Object
18 19 20 |
# File 'lib/aviator/core/utils/string.rb', line 18 def underscore(str) str.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase end |