Class: Evertils::Common::ENMLElement

Inherits:
Object
  • Object
show all
Defined in:
lib/evertils/common/enmlelement.rb

Overview

Since:

  • 0.3.0

Instance Method Summary collapse

Constructor Details

#initialize(colour) ⇒ ENMLElement

Returns a new instance of ENMLElement.

Since:

  • 0.3.3



6
7
8
9
10
# File 'lib/evertils/common/enmlelement.rb', line 6

def initialize(colour)
  @colour = colour
  @enml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  @enml += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
end

Instance Method Details

#body=(content) ⇒ Object

Since:

  • 0.3.3



14
15
16
17
18
19
20
# File 'lib/evertils/common/enmlelement.rb', line 14

def body=(content)
  # at some point between 10/30/2017 and 11/06/2017, adding bgcolor to
  # the root element started throwing EDAM code 11
  # (Content is not allowed in prolog).  Commenting out for now.
  # @enml += "<en-note bgcolor=\"##{@colour.to_s(16)}\">#{content}</en-note>"
  @enml += "<en-note>#{content}</en-note>"
end

#encodingObject

Required as part of the thrift data conversion

Since:

  • 0.3.3



30
31
32
# File 'lib/evertils/common/enmlelement.rb', line 30

def encoding
  Encoding::UTF_8
end

#force_encoding(enc) ⇒ Object

Required as part of the thrift data conversion

Since:

  • 0.3.3



36
37
38
# File 'lib/evertils/common/enmlelement.rb', line 36

def force_encoding(enc)
  @enml.to_s.encode(enc)
end

#to_sObject

Since:

  • 0.3.3



24
25
26
# File 'lib/evertils/common/enmlelement.rb', line 24

def to_s
  @enml.to_s.encode(Encoding::UTF_8)
end