Sha256: 361f96fd678d6ccb99131d48c5b760205672ca2e00c52972be32fe5ab910b473

Contents?: true

Size: 254 Bytes

Versions: 5

Compression:

Stored size: 254 Bytes

Contents

# frozen_string_literal: true

module StringHelpers
  def self.underscore(str)
    str
      .to_s
      .gsub(/::/, '/')
      .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
      .gsub(/([a-z\d])([A-Z])/, '\1_\2')
      .tr('-', '_')
      .downcase
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
psu_identity-0.6.1 lib/psu_identity/string_helpers.rb
psu_identity-0.6.0 lib/psu_identity/string_helpers.rb
psu_identity-0.5.1 lib/psu_identity/string_helpers.rb
psu_identity-0.5.0 lib/psu_identity/string_helpers.rb
psu_identity-0.4.0 lib/psu_identity/string_helpers.rb