Sha256: 99d9b4c9bf02bf38fc83013c097203f4452a1b8c081dcd6eddcc6f597bdc4797

Contents?: true

Size: 604 Bytes

Versions: 5

Compression:

Stored size: 604 Bytes

Contents

module RubyIsds
  module Responses
    module Messages
      class Attachment
        attr_accessor :file_type, :file_name, :encoded_content, :decoded_content

        def initialize(hash)
          @file_type = hash['dmMimeType']
          @file_name = hash['dmFileDescr']
          @encoded_content = hash['dmEncodedContent']
          @decoded_content = Base64.decode64(@encoded_content)
        end

        def download(destination = '/tmp')
          File.open("#{destination}/#{@file_name}", 'wb') do |f|
            f.write(@decoded_content)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby_isds-0.10.3 lib/ruby_isds/responses/messages/attachment.rb
ruby_isds-0.10.2 lib/ruby_isds/responses/messages/attachment.rb
ruby_isds-0.10.1 lib/ruby_isds/responses/messages/attachment.rb
ruby_isds-0.9.1 lib/ruby_isds/responses/messages/attachment.rb
ruby_isds-0.9.0 lib/ruby_isds/responses/messages/attachment.rb