Sha256: 31ef54dc2d5c2a658583c7bf679c80ef3f8940822c4dd0c45595c2fc921a54ac

Contents?: true

Size: 321 Bytes

Versions: 39

Compression:

Stored size: 321 Bytes

Contents

class String

   # "FooBar".snake_case #=> "foo_bar"
   def snake_case
     gsub(/\B[A-Z]/, '_\&').downcase
   end

   # "foo_bar".camel_case #=> "FooBar"
   def camel_case
     str = gsub(/^[a-z]|_+[a-z]/) { |a| a.upcase }
     str.gsub(/_/, '')
   end

   def dash_case
     self.snake_case.gsub('_', '-')
   end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
sprout-1.0.23.pre lib/sprout/string.rb
sprout-1.0.22.pre lib/sprout/string.rb
sprout-1.0.20.pre lib/sprout/string.rb
sprout-1.0.19.pre lib/sprout/string.rb
sprout-1.0.18.pre lib/sprout/string.rb
sprout-1.0.17.pre lib/sprout/string.rb
sprout-1.0.16.pre lib/sprout/string.rb
sprout-1.0.15.pre lib/sprout/string.rb
sprout-1.0.14.pre lib/sprout/string.rb
sprout-1.0.13.pre lib/sprout/string.rb
sprout-1.0.11.pre lib/sprout/string.rb
sprout-1.0.9.pre lib/sprout/string.rb
sprout-1.0.8.pre lib/sprout/string.rb
sprout-1.0.5.pre lib/sprout/string.rb
sprout-1.0.4.pre lib/sprout/string.rb
sprout-1.0.3.pre lib/sprout/string.rb
sprout-1.0.2.pre lib/sprout/string.rb
sprout-1.0.1.pre lib/sprout/string.rb
sprout-1.0.0.pre lib/sprout/string.rb