class String

Flox-extensions to the standard Time class.

Public Class Methods

random_uid(length=16) click to toggle source

@return [String] creates a random alphanumeric string with a given length.

# File lib/flox/utils.rb, line 22
def self.random_uid(length=16)
  SecureRandom.base64(length * 2).gsub(/[\+\/]/, '').slice(0, length)
end

Public Instance Methods

to_camelcase() click to toggle source

@return [String] converts a string that separates its words with space,

underscore or dash into its `camelCase` equivalent.
# File lib/flox/utils.rb, line 33
def to_camelcase
  words = downcase.split(/[_\-\s]/)
  words.shift + words.map(&:capitalize).join
end
to_underscore() click to toggle source

@return [String] converts a `camelCase` string to its `under_score` equivalent.

# File lib/flox/utils.rb, line 27
def to_underscore
  gsub(/(.)([A-Z])/,'\1_\2').downcase
end