@@ -128,7 +128,7 @@ def transliterate!(*kinds)
128128 # replaces multiple whitespace characters with a single space.
129129 # @return String
130130 def clean!
131- @wrapped_string = gsub ( /[- ]+/ , " " )
131+ gsub! ( /[- ]+/ , " " )
132132 strip!
133133 @wrapped_string
134134 end
@@ -141,7 +141,8 @@ def word_chars!
141141 # `\P{L}` = Any non-Unicode letter
142142 # `&&` = add the following character class
143143 # `[^ _\n\r]` = Anything other than space, underscore, newline or linefeed
144- @wrapped_string = gsub ( /[\P {L}&&[^ _\n \r ]]/ , "" )
144+ gsub! ( /[\P {L}&&[^ _\n \r ]]/ , "" )
145+ @wrapped_string
145146 end
146147
147148 # Normalize the string for use as a URL slug. Note that in this context,
@@ -186,7 +187,8 @@ def to_ruby_method!(allow_bangs = true)
186187 # Delete any non-ascii characters.
187188 # @return String
188189 def to_ascii!
189- @wrapped_string = gsub ( /[^\x00 -\x7f ]/u , "" )
190+ gsub! ( /[^\x00 -\x7f ]/u , "" )
191+ @wrapped_string
190192 end
191193
192194 # Truncate the string to +max+ characters.
@@ -221,22 +223,25 @@ def truncate_bytes!(max)
221223 # Replaces whitespace with dashes ("-").
222224 # @return String
223225 def with_separators! ( char = "-" )
224- @wrapped_string = gsub ( /\s /u , char )
226+ gsub! ( /\s /u , char )
227+ @wrapped_string
225228 end
226229
227230 # Perform Unicode composition on the wrapped string.
228231 # @return String
229232 def normalize_utf8!
230- @wrapped_string = unicode_normalize ( :nfc )
233+ unicode_normalize! ( :nfc )
234+ @wrapped_string
231235 end
232236
233237 # Attempt to convert characters encoded using CP1252 and IS0-8859-1 to
234238 # UTF-8.
235239 # @return String
236240 def tidy_bytes!
237- @wrapped_string = scrub do |bad |
241+ scrub! do |bad |
238242 tidy_byte ( *bad . bytes ) . flatten . compact . pack ( "C*" ) . force_encoding ( "UTF-8" )
239243 end
244+ @wrapped_string
240245 end
241246
242247 %w[ transliterate clean downcase word_chars normalize normalize_utf8
0 commit comments