Class: Rlt::Utils::StringUtil
- Inherits:
-
Object
- Object
- Rlt::Utils::StringUtil
- Defined in:
- lib/rlt/utils/string_util.rb
Class Method Summary collapse
Class Method Details
.short_random_string ⇒ Object
14 15 16 |
# File 'lib/rlt/utils/string_util.rb', line 14 def self.short_random_string (0...4).map { rand(65..90).chr }.join end |
.underscore(str) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/rlt/utils/string_util.rb', line 6 def self.underscore(str) str.gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end |