class Rlt::Utils::StringUtil

Public Class Methods

short_random_string() click to toggle source
# 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) click to toggle source
# 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