Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/flox/utils.rb

Overview

Flox-extensions to the standard Time class.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.random_uid(length = 16) ⇒ String



22
23
24
# File 'lib/flox/utils.rb', line 22

def self.random_uid(length=16)
  SecureRandom.base64(length * 2).gsub(/[\+\/]/, '').slice(0, length)
end

Instance Method Details

#to_camelcaseString



33
34
35
36
# File 'lib/flox/utils.rb', line 33

def to_camelcase
  words = downcase.split(/[_\-\s]/)
  words.shift + words.map(&:capitalize).join
end

#to_underscoreString



27
28
29
# File 'lib/flox/utils.rb', line 27

def to_underscore
  gsub(/(.)([A-Z])/,'\1_\2').downcase
end