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