Method: Redwood::ForwardMode#initialize

Defined in:
lib/sup/modes/forward_mode.rb

#initialize(opts = {}) ⇒ ForwardMode

TODO: share some of this with reply-mode



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sup/modes/forward_mode.rb', line 16

def initialize opts={}
  header = {
    "From" => AccountManager..full_address,
  }

  @m = opts[:message]
  header["Subject"] =
    if @m
      "Fwd: " + @m.subj
    elsif opts[:attachments]
      "Fwd: " + opts[:attachments].keys.join(", ")
    end

  header["To"] = opts[:to].map { |p| p.full_address }.join(", ") if opts[:to]
  header["Cc"] = opts[:cc].map { |p| p.full_address }.join(", ") if opts[:cc]
  header["Bcc"] = opts[:bcc].map { |p| p.full_address }.join(", ") if opts[:bcc]

  body =
    if @m
      forward_body_lines @m
    elsif opts[:attachments]
      ["Note: #{opts[:attachments].size.pluralize 'attachment'}."]
    end

  super :header => header, :body => body, :attachments => opts[:attachments]
end