Class: Strings::Urlize

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dear_inventory/lib/strings/urlize.rb

Class Method Summary collapse

Class Method Details

.call(camel_cased_word) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/dear_inventory/lib/strings/urlize.rb', line 9

def self.call(camel_cased_word)
  return camel_cased_word unless /[A-Z_]/.match?(camel_cased_word)

  camel_cased_word.
    gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1-\2').
    gsub(/([a-z\d])([A-Z])/, '\1-\2').
    downcase
end