Module: Snippit::Slugify

Included in:
CLI::Save
Defined in:
lib/snippit/slugify.rb

Overview

Provides the slugify function

Instance Method Summary collapse

Instance Method Details

#slugify(str) ⇒ String

Slugify a string

Parameters:

  • str (String)

    The string to slugify

Returns:

  • (String)

    The slugified string



10
11
12
# File 'lib/snippit/slugify.rb', line 10

def slugify(str)
  str.strip.downcase.gsub(/ /, '-').gsub(/[^a-z0-9\-_.]/, '')
end