Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/comun.rb
Overview
end Y quiero que los strings no tengan espacios extraños
Instance Method Summary collapse
-
#squish ⇒ String
Limpia whitespace de extremos y espacios repetidos.
-
#squish! ⇒ String
Lo mismo que squish, pero destructivo.
Instance Method Details
#squish ⇒ String
Limpia whitespace de extremos y espacios repetidos
18 19 20 |
# File 'lib/comun.rb', line 18 def squish dup.squish! end |
#squish! ⇒ String
Lo mismo que squish, pero destructivo
25 26 27 28 29 |
# File 'lib/comun.rb', line 25 def squish! strip! gsub!(/\s(\s+)/, ' ') self end |