Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor/foodogsquared/helpers.rb

Instance Method Summary collapse

Instance Method Details

#to_kebabObject



4
5
6
7
8
9
10
# File 'lib/asciidoctor/foodogsquared/helpers.rb', line 4

def to_kebab
  self.gsub(/\s+/, '-')           # Replace all spaces with dashes.
      .gsub(/[^a-zA-Z0-9-]/, '')  # Remove all non-alphanumerical (and dashes) characters.
      .gsub(/-+/, '-')            # Reduce all dashes into only one.
      .gsub(/^-|-+$/, '')         # Remove all leading and trailing dashes.
      .downcase
end