Module: Surveyor::Models::SurveyMethods::ClassMethods

Defined in:
lib/surveyor/models/survey_methods.rb

Instance Method Summary collapse

Instance Method Details

#to_normalized_string(value) ⇒ Object



28
29
30
31
# File 'lib/surveyor/models/survey_methods.rb', line 28

def to_normalized_string(value)
  # replace non-alphanumeric with "-". remove repeat "-"s. don't start or end with "-"
  value.to_s.downcase.gsub(/[^a-z0-9]/,"-").gsub(/-+/,"-").gsub(/-$|^-/,"")
end