Sha256: 8932d44a880c3c55523c51487fa9fdbf6b8ad82e09b2312b0ba83a42f2792189

Contents?: true

Size: 998 Bytes

Versions: 20

Compression:

Stored size: 998 Bytes

Contents

module Evertils
  module Common
    class ENML
      attr_reader :element, :embeddable_element

      def initialize(file = nil)
        @file = file
        @element = enml_element

        if !@element.nil?
          @embeddable_element = "<hr/>Attachment with hash #{@element.data.bodyHash}<br /><en-media type=\"#{@element.mime}\" hash=\"#{@element.data.bodyHash}\" /><br /><br />"
        end
      end

      private

      def enml_element
        read_file = File.open(@file, 'rb') { |io| io.read }

        el = ::Evernote::EDAM::Type::Resource.new()
        el.mime = MIME::Types.type_for(@file)[0].content_type
        el.data = ::Evernote::EDAM::Type::Data.new()
        el.data.size = read_file.size
        el.data.bodyHash = Digest::MD5.hexdigest(read_file)
        el.data.body = read_file
        el.attributes = ::Evernote::EDAM::Type::ResourceAttributes.new()
        el.attributes.fileName = @file # temporary for now, the actual file name
        el
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
evertils-common-0.3.18 lib/evertils/common/enml.rb
evertils-common-0.3.17 lib/evertils/common/enml.rb
evertils-common-0.3.16 lib/evertils/common/enml.rb
evertils-common-0.3.15 lib/evertils/common/enml.rb
evertils-common-0.3.14 lib/evertils/common/enml.rb
evertils-common-0.3.13 lib/evertils/common/enml.rb
evertils-common-0.3.12 lib/evertils/common/enml.rb
evertils-common-0.3.11 lib/evertils/common/enml.rb
evertils-common-0.3.10 lib/evertils/common/enml.rb
evertils-common-0.3.9 lib/evertils/common/enml.rb
evertils-common-0.3.8 lib/evertils/common/enml.rb
evertils-common-0.3.7 lib/evertils/common/enml.rb
evertils-common-0.3.6 lib/evertils/common/enml.rb
evertils-common-0.3.5 lib/evertils/common/enml.rb
evertils-common-0.3.4.1 lib/evertils/common/enml.rb
evertils-common-0.3.4 lib/evertils/common/enml.rb
evertils-common-0.3.4.1.pre.dev lib/evertils/common/enml.rb
evertils-common-0.3.3.1 lib/evertils/common/enml.rb
evertils-common-0.3.3 lib/evertils/common/enml.rb
evertils-common-0.3.2 lib/evertils/common/enml.rb