Sha256: a62734f61cc2c420e6fc015d065914626b1a18d0a61579bd67e48b929aee7303

Contents?: true

Size: 249 Bytes

Versions: 1

Compression:

Stored size: 249 Bytes

Contents

# frozen_string_literal: true

class String
  # Transform string to snake case
  def underscore
    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

1 entries across 1 versions & 1 rubygems

Version Path
bungie_client-2.2.0 lib/underscore.rb