Sha256: 230c1fa9f9dabd55973b22e08905b04ec09f905a9c2edccb23f60d97ce298781

Contents?: true

Size: 360 Bytes

Versions: 8

Compression:

Stored size: 360 Bytes

Contents

#          Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

# Extensions for String

class String

  # convert to snake_case from CamelCase
  #
  #   'FooBar'.snake_case # => 'foo_bar'

  def snake_case
    gsub(/\B[A-Z][^A-Z]/, '_\&').downcase.gsub(' ', '_')
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
clivecrous-ramaze-0.3.9.5 lib/ramaze/snippets/string/snake_case.rb
manveru-ramaze-2008.07 lib/ramaze/snippets/string/snake_case.rb
manveru-ramaze-2008.08 lib/ramaze/snippets/string/snake_case.rb
ramaze-0.3.0 lib/ramaze/snippets/string/snake_case.rb
ramaze-0.3.5 lib/ramaze/snippets/string/snake_case.rb
ramaze-2008.06 lib/ramaze/snippets/string/snake_case.rb
ramaze-0.3.9.1 lib/ramaze/snippets/string/snake_case.rb
ramaze-0.3.9 lib/ramaze/snippets/string/snake_case.rb