module Typist::Util
This module contains common logic used throughout the gem.
Public Class Methods
snakeify(string)
click to toggle source
Convert a CamelCase String to snake_case. Shamelessly stolen from ActiveSupport.
# File lib/typist/util.rb, line 5 def snakeify(string) string.to_s. gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end
Private Instance Methods
snakeify(string)
click to toggle source
Convert a CamelCase String to snake_case. Shamelessly stolen from ActiveSupport.
# File lib/typist/util.rb, line 5 def snakeify(string) string.to_s. gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end