Method: String#wrap

Defined in:
lib/extra/string.rb

#wrap(width = 80, separator = $/) ⇒ Object

Wrap string by characters and join them by a specified separator.

Example: "1234".wrap(2) #=> "12\n34"

Returns: String



205
206
207
# File 'lib/extra/string.rb', line 205

def wrap(width = 80, separator = $/)
  scan(/.{1,#{width}}/u).join(separator)
end