Sha256: df672029acd2bbbcf75a2244706cf083abc7d4aa337f33c434bd47664d34ae6b

Contents?: true

Size: 604 Bytes

Versions: 4

Compression:

Stored size: 604 Bytes

Contents

module CoreExtensions
  module String
  
    def slugorize
      result = self.downcase
      result.gsub!(/&([0-9a-z#])+;/, '')  # Ditch Entities
      result.gsub!('&', 'and')            # Replace & with 'and'
      result.gsub!(/[^a-z0-9\-']/, '-')   # Get rid of anything we don't like
      result.gsub!(/-+/, '-')             # collapse dashes
      result.gsub!(/-$/, '')              # trim dashes
      result.gsub!(/^-/, '')              # trim dashes
      result
    end

    def slugorize!
      self.replace(self.slugorize)
    end

  end
end

String.send(:include, CoreExtensions::String)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
enki-engine-0.0.5 lib/core_extensions/string.rb
enki-engine-0.0.4 lib/core_extensions/string.rb
enki-engine-0.0.3 lib/core_extensions/string.rb
enki-engine-0.0.2 lib/core_extensions/string.rb