Sha256: 3e3bcd3d0787c87cd74de0c21efac00e3740ca96d35e05ef059f7a89122233b1
Contents?: true
Size: 359 Bytes
Versions: 5
Compression:
Stored size: 359 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 # Alias to .to_snake def underscore self.to_snake end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
omniauth-dice-0.1.5 | lib/string.rb |
omniauth-dice-0.1.4 | lib/string.rb |
omniauth-dice-0.1.3 | lib/string.rb |
omniauth-dice-0.1.2 | lib/string.rb |
omniauth-dice-0.1.1 | lib/string.rb |