Class: Mbox::Mail::File
- Inherits:
-
Object
- Object
- Mbox::Mail::File
- Defined in:
- lib/mbox/mail/file.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(headers, content) ⇒ File
constructor
A new instance of File.
- #inspect ⇒ Object
- #to_s ⇒ Object (also: #to_str)
Constructor Details
#initialize(headers, content) ⇒ File
Returns a new instance of File.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mbox/mail/file.rb', line 27 def initialize (headers, content) if headers[:content_type] content.force_encoding headers[:content_type].charset end if headers[:content_transfer_encoding] == 'base64' content = Base64.decode64(content) end if matches = headers[:content_disposition].match(/filename="(.*?)"/) rescue nil @name = matches[1] end @headers = headers @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
25 26 27 |
# File 'lib/mbox/mail/file.rb', line 25 def content @content end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
25 26 27 |
# File 'lib/mbox/mail/file.rb', line 25 def headers @headers end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/mbox/mail/file.rb', line 25 def name @name end |
Instance Method Details
#inspect ⇒ Object
50 51 52 |
# File 'lib/mbox/mail/file.rb', line 50 def inspect "#<File:#{name}>" end |
#to_s ⇒ Object Also known as: to_str
44 45 46 |
# File 'lib/mbox/mail/file.rb', line 44 def to_s @content end |