class String

Public Instance Methods

match?(*args) click to toggle source
# File lib/core_ext.rb, line 21
def match?(*args)
  !!match(*args)
end
symbolize() click to toggle source
# File lib/core_ext.rb, line 25
def symbolize
  underscore.to_sym
end
underscore() click to toggle source
# File lib/core_ext.rb, line 12
def underscore
  return self unless /[A-Z-]|::/.match?(self)
  to_s.gsub('::', '/')
      .gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
      .gsub(/([a-z\d])([A-Z])/, '\1_\2')
      .tr('- ', '_')
      .downcase
end