class Nav::Slug

Constants

Join

Public Class Methods

for(*args) click to toggle source
# File lib/rails_nav.rb, line 351
def Slug.for(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  join = (options[:join]||options['join']||Join).to_s
  string = args.flatten.compact.join(join)
  string = unidecode(string).titleize
  words = string.to_s.scan(%r/\w+/)
  words.map!{|word| word.gsub %r/[^0-9a-zA-Z_-]/, ''}
  words.delete_if{|word| word.nil? or word.strip.empty?}
  new(words.join(join).downcase)
end
unidecode(string) click to toggle source
# File lib/rails_nav.rb, line 368
def Slug.unidecode(string)
  string
end