Module: Ekispert::Util
- Included in:
- DataVersion, EkispertBase
- Defined in:
- lib/ekispert/util.rb
Instance Method Summary collapse
Instance Method Details
#snakecase(str) ⇒ Object
Ex. snakecase(‘GeoPoint’) #=> ‘geo_point’
4 5 6 7 8 9 |
# File 'lib/ekispert/util.rb', line 4 def snakecase(str) str = str.to_s return str unless /[A-Z-]/.match?(str) str.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase end |