Sha256: 4be757e84257b2fe0850294558b50249d73742e4f1c5253d75a821240a32901c

Contents?: true

Size: 677 Bytes

Versions: 6

Compression:

Stored size: 677 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_destination = "#{destination}/#{@file_name}"
          File.open(file_destination, 'wb') do |f|
            f.write(@decoded_content)
          end
          file_destination
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby_isds-0.13.0 lib/ruby_isds/responses/messages/attachment.rb
ruby_isds-0.12.0 lib/ruby_isds/responses/messages/attachment.rb
ruby_isds-0.11.1 lib/ruby_isds/responses/messages/attachment.rb
ruby_isds-0.11.0 lib/ruby_isds/responses/messages/attachment.rb
ruby_isds-0.10.5 lib/ruby_isds/responses/messages/attachment.rb
ruby_isds-0.10.4 lib/ruby_isds/responses/messages/attachment.rb