Sha256: b9e6b1e33f265d4da98a9ef077b69d9afb45ee29af25f3ff738d0e2bca1ba96a
Contents?: true
Size: 468 Bytes
Versions: 18
Compression:
Stored size: 468 Bytes
Contents
# -*- encoding : utf-8 -*- module Dao class Slug < ::String Join = '-' def Slug.for(*args) options = args.last.is_a?(Hash) ? args.pop : {} join = options[:join]||options['join']||Join string = args.flatten.compact.join(join) 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 end end
Version data entries
18 entries across 18 versions & 1 rubygems