private Method

Format.__make_line(line, indent, width, last = false)

There's no documentation for this item.

Source Code

# File action_mailer/vendor/text-format-0.6.3/text/format.rb, line 717
def __make_line(line, indent, width, last = false) #:nodoc:
  lmargin = " " * @left_margin
  fill = " " * (width - line.size) if right_fill? && (line.size <= width)

  if (justify? && ((not line.nil?) && (not line.empty?)) && line =~ /\S+\s+\S+/ && !last)
    spaces = width - line.size
    words = line.split(/(\s+)/)
    ws = spaces / (words.size / 2)
    spaces = spaces % (words.size / 2) if ws > 0
    words.reverse.each do |rw|
      next if (rw =~ /^\S/)
      rw.sub!(/^/, " " * ws)
      next unless (spaces > 0)
      rw.sub!(/^/, " ")
      spaces -= 1
    end
    line = words.join('')
  end
  line = "#{lmargin}#{indent}#{line}#{fill}\n" unless line.nil?
  if right_align? && (not line.nil?)
    line.sub(/^/, " " * (@columns - @right_margin - (line.size - 1)))
  else
    line
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.