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.1.18.pre lib/sprout/string.rb
sprout-1.1.17.pre lib/sprout/string.rb
sprout-1.1.16.pre lib/sprout/string.rb
sprout-1.1.15.pre lib/sprout/string.rb
sprout-1.1.14.pre lib/sprout/string.rb
sprout-1.1.13.pre lib/sprout/string.rb
sprout-1.1.11.pre lib/sprout/string.rb
sprout-1.1.10.pre lib/sprout/string.rb
sprout-1.1.7.pre lib/sprout/string.rb
sprout-1.1.5.pre lib/sprout/string.rb
sprout-1.1.4.pre lib/sprout/string.rb
sprout-1.1.3.pre lib/sprout/string.rb
sprout-1.1.2.pre lib/sprout/string.rb
sprout-1.0.35.pre lib/sprout/string.rb
sprout-1.0.32.pre lib/sprout/string.rb
sprout-1.0.31.pre lib/sprout/string.rb
sprout-1.0.29.pre lib/sprout/string.rb
sprout-1.0.26.pre lib/sprout/string.rb
sprout-1.0.25.pre lib/sprout/string.rb
sprout-1.0.24.pre lib/sprout/string.rb