Class: Heathrow::MessageComposer
- Inherits:
-
Object
- Object
- Heathrow::MessageComposer
- Defined in:
- lib/heathrow/message_composer.rb
Instance Attribute Summary collapse
-
#editor ⇒ Object
readonly
Returns the value of attribute editor.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#compose_draft(draft) ⇒ Object
Resume a postponed draft.
-
#compose_forward ⇒ Object
Compose a forward of a message.
-
#compose_new(to = nil, subject = nil) ⇒ Object
Compose a new message.
-
#compose_reply(include_all_recipients = false) ⇒ Object
Compose a reply to a message.
-
#initialize(message = nil, identity: nil, address_book: nil, editor_args: nil) ⇒ MessageComposer
constructor
A new instance of MessageComposer.
Constructor Details
#initialize(message = nil, identity: nil, address_book: nil, editor_args: nil) ⇒ MessageComposer
Returns a new instance of MessageComposer.
11 12 13 14 15 16 17 |
# File 'lib/heathrow/message_composer.rb', line 11 def initialize( = nil, identity: nil, address_book: nil, editor_args: nil) @message = @editor = ENV['EDITOR'] || 'vim' @identity = identity @address_book = address_book @editor_args = editor_args end |
Instance Attribute Details
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
9 10 11 |
# File 'lib/heathrow/message_composer.rb', line 9 def editor @editor end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/heathrow/message_composer.rb', line 9 def @message end |
Instance Method Details
#compose_draft(draft) ⇒ Object
Resume a postponed draft
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/heathrow/message_composer.rb', line 46 def compose_draft(draft) template = header_block( to: draft['to'] || '', cc: draft['cc'] || '', bcc: draft['bcc'] || '', subject: draft['subject'] || '', reply_to: draft['reply_to'] ) template << "" template << (draft['body'] || '') content = edit_in_editor(template.join("\n")) return nil if content.nil? || content.strip.empty? (content) end |
#compose_forward ⇒ Object
Compose a forward of a message
28 29 30 31 32 33 34 |
# File 'lib/heathrow/message_composer.rb', line 28 def compose_forward template = build_forward_template # Cursor on "To: " line (line 2) content = edit_in_editor(template, cursor_line: 2) return nil if content.nil? || content.strip.empty? (content) end |
#compose_new(to = nil, subject = nil) ⇒ Object
Compose a new message
37 38 39 40 41 42 43 |
# File 'lib/heathrow/message_composer.rb', line 37 def compose_new(to = nil, subject = nil) template = build_new_template(to, subject) # Cursor on "To: " line (line 2) content = edit_in_editor(template, cursor_line: 2) return nil if content.nil? || content.strip.empty? (content) end |
#compose_reply(include_all_recipients = false) ⇒ Object
Compose a reply to a message
20 21 22 23 24 25 |
# File 'lib/heathrow/message_composer.rb', line 20 def compose_reply(include_all_recipients = false) template = build_reply_template(include_all_recipients) content = edit_in_editor(template) return nil if content.nil? || content.strip.empty? (content) end |