Module: Riffer::Helpers::ClassNameConverter
Overview
Helper module for converting class names.
Constant Summary collapse
- DEFAULT_SEPARATOR =
"/"
Instance Method Summary collapse
-
#class_name_to_path(class_name, separator: DEFAULT_SEPARATOR) ⇒ Object
Converts a class name to snake_case identifier format.
Instance Method Details
#class_name_to_path(class_name, separator: DEFAULT_SEPARATOR) ⇒ Object
Converts a class name to snake_case identifier format.
- class_name
-
String - the class name (e.g., “Riffer::Agent”)
- separator
-
String - the separator to use for namespaces (default: “/”)
Returns String - the snake_case identifier (e.g., “riffer/agent”).
13 14 15 16 17 18 19 20 |
# File 'lib/riffer/helpers/class_name_converter.rb', line 13 def class_name_to_path(class_name, separator: DEFAULT_SEPARATOR) class_name .to_s .gsub("::", separator) .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .downcase end |