Files

ActionMailer::MailHelper

Public Instance Methods

attachments() click to toggle source

Access the message attachments list.

    # File lib/action_mailer/mail_helper.rb, line 28
28:     def attachments
29:       @_message.attachments
30:     end
block_format(text) click to toggle source

Uses Text::Format to take the text and format it, indented two spaces for each line, and wrapped at 72 columns.

    # File lib/action_mailer/mail_helper.rb, line 5
 5:     def block_format(text)
 6:       formatted = text.split(/\n\r\n/).collect { |paragraph|
 7:         format_paragraph(paragraph)
 8:       }.join("\n")
 9: 
10:       # Make list points stand on their own line
11:       formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| "  #{$1} #{$2.strip}\n" }
12:       formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| "  #{$1} #{$2.strip}\n" }
13: 
14:       formatted
15:     end
format_paragraph(text, len = 72, indent = 2) click to toggle source

Returns text wrapped at len columns and indented indent spaces.

Examples

  my_text = "Here is a sample text with more than 40 characters"

  format_paragraph(my_text, 25, 4)
  # => "    Here is a sample text with\n    more than 40 characters"
    # File lib/action_mailer/mail_helper.rb, line 40
40:     def format_paragraph(text, len = 72, indent = 2)
41:       sentences = [[]]
42: 
43:       text.split.each do |word|
44:         if (sentences.last + [word]).join(' ').length > len
45:           sentences << [word]
46:         else
47:           sentences.last << word
48:         end
49:       end
50: 
51:       sentences.map { |sentence|
52:         "#{" " * indent}#{sentence.join(' ')}"
53:       }.join "\n"
54:     end
mailer() click to toggle source

Access the mailer instance.

    # File lib/action_mailer/mail_helper.rb, line 18
18:     def mailer
19:       @_controller
20:     end
message() click to toggle source

Access the message instance.

    # File lib/action_mailer/mail_helper.rb, line 23
23:     def message
24:       @_message
25:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.