module Remotus::CoreExt::String

String extension module

Public Instance Methods

to_method_name() click to toggle source

Converts a string into a safe method name that can be used for instance variables

@return [Symbol] Method name

# File lib/remotus/core_ext/string.rb, line 14
def to_method_name
  gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z])([A-Z])/, '\1_\2')
    .tr(" ", "_")
    .gsub(/(?:[^_a-zA-Z0-9]|^\d+)/, "")
    .downcase
    .to_sym
end