class Serpscan::Utilities

Public Class Methods

object_to_string(object) click to toggle source
# File lib/serpscan/utilities.rb, line 4
def object_to_string(object)
  object_name = object.is_a?(Class) ? object.name : object.class
  underscore(object_name.to_s.split('::').last).downcase
end
underscore(string) click to toggle source
# File lib/serpscan/utilities.rb, line 9
def underscore(string)
  string.gsub(/::/, '/')
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .tr('-', '_')
    .downcase
end