Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/jquery-cheat.rb
Instance Method Summary collapse
Instance Method Details
#word_wrap(cols, padding = 0) ⇒ Object
103 104 105 |
# File 'lib/jquery-cheat.rb', line 103 def word_wrap cols, padding = 0 gsub(/\n\n/, "\r").gsub(/\n/, ' ').gsub(/\r/, "\n\n#{' ' * 14}").gsub(/(.{1,#{cols}}|\S{#{cols + 1},})(?: +|$\n?)/, "\\1\n#{ ' ' * padding}") end |