Class: RubyIsds::Responses::Messages::Attachment
- Inherits:
-
Object
- Object
- RubyIsds::Responses::Messages::Attachment
- Defined in:
- lib/ruby_isds/responses/messages/attachment.rb
Instance Attribute Summary collapse
-
#decoded_content ⇒ Object
Returns the value of attribute decoded_content.
-
#encoded_content ⇒ Object
Returns the value of attribute encoded_content.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#file_type ⇒ Object
Returns the value of attribute file_type.
Instance Method Summary collapse
- #download(destination = '/tmp') ⇒ Object
-
#initialize(hash) ⇒ Attachment
constructor
A new instance of Attachment.
Constructor Details
#initialize(hash) ⇒ Attachment
Returns a new instance of Attachment.
7 8 9 10 11 12 |
# File 'lib/ruby_isds/responses/messages/attachment.rb', line 7 def initialize(hash) @file_type = hash['dmMimeType'] @file_name = hash['dmFileDescr'] @encoded_content = hash['dmEncodedContent'] @decoded_content = Base64.decode64(@encoded_content) end |
Instance Attribute Details
#decoded_content ⇒ Object
Returns the value of attribute decoded_content.
5 6 7 |
# File 'lib/ruby_isds/responses/messages/attachment.rb', line 5 def decoded_content @decoded_content end |
#encoded_content ⇒ Object
Returns the value of attribute encoded_content.
5 6 7 |
# File 'lib/ruby_isds/responses/messages/attachment.rb', line 5 def encoded_content @encoded_content end |
#file_name ⇒ Object
Returns the value of attribute file_name.
5 6 7 |
# File 'lib/ruby_isds/responses/messages/attachment.rb', line 5 def file_name @file_name end |
#file_type ⇒ Object
Returns the value of attribute file_type.
5 6 7 |
# File 'lib/ruby_isds/responses/messages/attachment.rb', line 5 def file_type @file_type end |
Instance Method Details
#download(destination = '/tmp') ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ruby_isds/responses/messages/attachment.rb', line 14 def download(destination = '/tmp') file_destination = "#{destination}/#{@file_name}" File.open(file_destination, 'wb') do |f| f.write(@decoded_content) end file_destination end |