Sha256: 150b02f7c7c5f35b2b9f5025edef2a467c20369fbe736601949c8b02ee3fb0f3

Contents?: true

Size: 361 Bytes

Versions: 23

Compression:

Stored size: 361 Bytes

Contents

class String
  #
  # Convert from camel case to snake case
  #
  #     'FooBar'.snake_case # => "foo_bar"
  #

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

  #
  # Convert from snake case to camel case
  #
  #     'foo_bar'.camel_case # => "FooBar"
  #

  def camel_case
   split('_').map { |e| e.capitalize }.join
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
webidl-0.2.2 lib/webidl/extensions/string.rb
webidl-0.2.1 lib/webidl/extensions/string.rb
webidl-0.1.10 lib/webidl/extensions/string.rb
webidl-0.2.0 lib/webidl/extensions/string.rb
webidl-0.1.9 lib/webidl/extensions/string.rb
webidl-0.1.8 lib/webidl/extensions/string.rb
webidl-0.1.7 lib/webidl/extensions/string.rb
webidl-0.1.6 lib/webidl/extensions/string.rb
webidl-0.1.5 lib/webidl/extensions/string.rb
webidl-0.1.4 lib/webidl/extensions/string.rb
webidl-0.1.3 lib/webidl/extensions/string.rb
webidl-0.1.2 lib/webidl/extensions/string.rb
webidl-0.1.1 lib/webidl/extensions/string.rb
webidl-0.1.0 lib/webidl/extensions/string.rb
webidl-0.0.9 lib/webidl/extensions/string.rb
webidl-0.0.8 lib/webidl/extensions/string.rb
webidl-0.0.7 lib/webidl/extensions/string.rb
webidl-0.0.6 lib/webidl/extensions/string.rb
webidl-0.0.5 lib/webidl/extensions/string.rb
webidl-0.0.4 lib/webidl/extensions/string.rb