instance method simple_format

Ruby on Rails 3.0.20

Since v3.0.20 Last seen in v3.0.20 Private

Signature

simple_format(text, len = 72, indent = 2)

No documentation comment.

Parameters

text req
len opt = 72
indent opt = 2
Source
# File actionmailer/lib/action_mailer/mail_helper.rb, line 33
    def simple_format(text, len = 72, indent = 2)
      sentences = [[]]

      text.split.each do |word|
        if (sentences.last + [word]).join(' ').length > len
          sentences << [word]
        else
          sentences.last << word
        end
      end

      sentences.map { |sentence|
        "#{" " * indent}#{sentence.join(' ')}"
      }.join "\n"
    end

Defined in actionmailer/lib/action_mailer/mail_helper.rb line 33 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionMailer::MailHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close