module Votd::Helper::CommandLine
This module contains helper methods that support the command-line application
Public Instance Methods
word_wrap(text, line_width=40)
click to toggle source
Word-wraps text to the specified column width. @param [String] text the text to be wrapped @param [Integer] line_width column width @return [String] wrapped text
# File lib/votd/helper/command_line.rb, line 33 def word_wrap(text, line_width=40) text.split("\n").collect do |line| line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line end * "\n" end