private Method

Format.__center(to_center)

center text using spaces on left side to pad it out empty lines are preserved

Source Code

# File action_mailer/vendor/text-format-0.6.3/text/format.rb, line 682
def __center(to_center) #:nodoc:
  tabs = 0
  width = @columns - @left_margin - @right_margin
  centered = []
  to_center.each do |tc|
    s = tc.strip
    tabs = s.count("\t")
    tabs = 0 if tabs.nil?
    ct = ((width - s.size - (tabs * @tabstop) + tabs) / 2)
    ct = (width - @left_margin - @right_margin) - ct
    centered << "#{s.rjust(ct)}\n"
  end
  centered.join('')
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.