module Slugity::Util
Public Class Methods
normalize_string(string)
click to toggle source
# File lib/slugity/utilities.rb, line 6 def normalize_string string trim_string(string.to_s) rescue NoMethodError raise ArgumentError, "You must pass an object that respond to #to_s" end
trim_string(string)
click to toggle source
Trims begining and ending spaces from the string
@param string [String] @return [String] the string without begining and ending spaces
# File lib/slugity/utilities.rb, line 17 def trim_string string # capture spaces at the begining or end of the string pattern = /(^\s+|\s+$)/ # strip characters that match the pattern string.gsub( pattern, '' ) end