Sha256: c8ffa66f834aaf2cb966a741240695b18f5104665dbb51e4ece17cdf99d39b2c

Contents?: true

Size: 229 Bytes

Versions: 5

Compression:

Stored size: 229 Bytes

Contents

class String
  # Transform string to snake case
  def underscore
    self.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
bungie_client-1.1.1 lib/underscore.rb
bungie_client-1.1.0 lib/underscore.rb
bungie_client-1.0.3 lib/underscore.rb
bungie_client-1.0.2 lib/underscore.rb
bungie_client-1.0.0 lib/underscore.rb