Sha256: f7f5ef21366a2b8e61db25adfcc41603a6d9c5f898f534eaa11a25e9a8158c50

Contents?: true

Size: 294 Bytes

Versions: 6

Compression:

Stored size: 294 Bytes

Contents

#
# Extend the core String class to include `.to_snake`
#
class String
  # Attempts to convert a string into a formatted_snake_case_string
  def to_snake
    self.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
        .gsub(/([a-z\d])([A-Z])/, '\1_\2')
        .tr('-', '_')
        .downcase
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
omniauth-dice-0.2.1 lib/string.rb
omniauth-dice-0.2.0 lib/string.rb
omniauth-dice-0.1.9 lib/string.rb
omniauth-dice-0.1.8 lib/string.rb
omniauth-dice-0.1.7 lib/string.rb
omniauth-dice-0.1.6 lib/string.rb