Class: MailBuilder::Attachment
- Inherits:
-
Object
- Object
- MailBuilder::Attachment
- Defined in:
- lib/mail_builder/attachment.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(file, name, type, headers) ⇒ Attachment
constructor
A new instance of Attachment.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file, name, type, headers) ⇒ Attachment
Returns a new instance of Attachment.
6 7 8 9 10 11 12 13 14 |
# File 'lib/mail_builder/attachment.rb', line 6 def initialize(file, name, type, headers) @file = file @name = name @type = type @headers = headers # If we have a File/IO object, read it. Otherwise, we'll read it lazily. @body = file.read() if !file.kind_of?(Pathname) && file.respond_to?(:read) end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
4 5 6 |
# File 'lib/mail_builder/attachment.rb', line 4 def file @file end |
#headers ⇒ Object
Returns the value of attribute headers.
4 5 6 |
# File 'lib/mail_builder/attachment.rb', line 4 def headers @headers end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/mail_builder/attachment.rb', line 4 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/mail_builder/attachment.rb', line 4 def type @type end |
Instance Method Details
#inspect ⇒ Object
30 31 32 |
# File 'lib/mail_builder/attachment.rb', line 30 def inspect "#<MailBuilder::Attachment @file=#{@file.inspect}> @name=#{@name.inspect} @type=#{@type.inspect} @headers=#{@headers.inspect}" end |
#to_s ⇒ Object
16 17 18 19 20 |
# File 'lib/mail_builder/attachment.rb', line 16 def to_s @body ||= File.open(file.to_s(), "rb") { |f| f.read() } [@body].pack("m") end |