Sha256: 67cb0a60c17201e111caafe1c53c16f0465c97e7ccf83fd0cc15feae3157cc98

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 Bytes

Contents

module Redwood

class ComposeMode < EditMessageMode
  attr_reader :body, :header

  def initialize opts={}
    super()
    @header = {
      "From" => AccountManager.default_account.full_address,
      "Message-Id" => gen_message_id,
    }

    @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]
    @header["Subject"] = opts[:subj] if opts[:subj]

    @body = (opts[:body] || []) + sig_lines
    regen_text
  end

  def lines; @text.length; end
  def [] i; @text[i]; end

protected

  def handle_new_text new_header, new_body
    @header = new_header
    @body = new_body
  end

  def regen_text
    @text = header_lines(@header - EditMessageMode::NON_EDITABLE_HEADERS) + [""] + @body
  end
end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sup-0.0.7 lib/sup/modes/compose-mode.rb
sup-0.0.8 lib/sup/modes/compose-mode.rb