Class: MIMEBuilder::Text
- Inherits:
-
Object
- Object
- MIMEBuilder::Text
- Defined in:
- lib/mime_builder/text.rb
Instance Attribute Summary collapse
-
#mime ⇒ Object
Returns the value of attribute mime.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #get_attachment_content_disposition(filename = nil) ⇒ Object
-
#initialize(text, opts = {}) ⇒ Text
constructor
A new instance of Text.
- #set_attachment_content_disposition(filename, is_attachment) ⇒ Object
Constructor Details
#initialize(text, opts = {}) ⇒ Text
Returns a new instance of Text.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mime_builder/text.rb', line 8 def initialize(text, opts = {}) @text = text if opts.key?(:content_type) && opts[:content_type].to_s.length>0 content_type = opts[:content_type] if content_type =~ /^text\/([^\/]+)$/i @mime = MIME::Text.new(text, $1.downcase) else raise "Unknown Content Type: " + opts[:content_type].to_s end else @mime = MIME::Text.new(text, 'plain') end @mime.headers.delete('Content-Id') \ if opts.key?(:content_id_disable) && opts[:content_id_disable] (opts[:filename], opts[:is_attachment]) end |
Instance Attribute Details
#mime ⇒ Object
Returns the value of attribute mime.
5 6 7 |
# File 'lib/mime_builder/text.rb', line 5 def mime @mime end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/mime_builder/text.rb', line 6 def text @text end |
Instance Method Details
#get_attachment_content_disposition(filename = nil) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/mime_builder/text.rb', line 35 def (filename = nil) if filename.to_s.length > 0 return "attachment; filename=\"#{filename}\"" end 'attachment' end |
#set_attachment_content_disposition(filename, is_attachment) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/mime_builder/text.rb', line 28 def (filename, ) @mime.headers.set( 'Content-Disposition', (filename) ) if end |