Class: String
Overview
This is not yet applicable to the message body, itself.
Constant Summary
Constants included from BasicLogging
BasicLogging::DEBUG, BasicLogging::ERROR, BasicLogging::FATAL, BasicLogging::INFO, BasicLogging::Levels, BasicLogging::UNKNOWN, BasicLogging::WARN
Instance Method Summary collapse
-
#wrap!(length = WRAP_LENGTH, indent = 0) ⇒ Object
wraps at length, returns the result.
Methods included from BasicLogging
#clear_log, is_muted?, #level, #log, mute, #set_level, #set_target, #target
Instance Method Details
#wrap!(length = WRAP_LENGTH, indent = 0) ⇒ Object
wraps at length, returns the result
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/body.rb', line 27 def wrap! (length = WRAP_LENGTH, indent = 0) max = length line = 0 out = [""] self.gsub!("\r\n", " ") self.gsub!(" ", " ") words = self.split(" ") while !words.empty? word = words.shift.strip break if not word if out[line].length + word.length > max out[line].squeeze!(" ") line += 1 out[line] = (line > 0 ? " " * indent : "") end out[line] << word + " " end self.replace( out.join("\r\n")) end |