Sha256: dbeb01d8d029b475453743fcd4919b35fbbe18e0a1fe77af59f043d426fa4da8

Contents?: true

Size: 416 Bytes

Versions: 6

Compression:

Stored size: 416 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module Strings
  class Urlize
    extend T::Sig

    sig { params(camel_cased_word: String).returns(String) }
    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dear_inventory-1.4.0 lib/dear_inventory/lib/strings/urlize.rb
dear_inventory-1.3.0 lib/dear_inventory/lib/strings/urlize.rb
dear_inventory-1.2.0 lib/dear_inventory/lib/strings/urlize.rb
dear_inventory-1.1.1 lib/dear_inventory/lib/strings/urlize.rb
dear_inventory-1.1.0 lib/dear_inventory/lib/strings/urlize.rb
dear_inventory-1.0.0 lib/dear_inventory/lib/strings/urlize.rb