Sha256: f800c184cb9ab4bc8cbb98a953631b78d2389091c6324c13ccd8cacc9eb70133

Contents?: true

Size: 888 Bytes

Versions: 3

Compression:

Stored size: 888 Bytes

Contents

module Evertils
  module Helper
    class ApiEnmlHandler
      #
      # @since 0.3.7
      def initialize(config = nil)
        @config = config
        self
      end

      #
      # @since 0.3.13
      def from_str(str)
        @xml = Nokogiri::XML::DocumentFragment.parse(str)
      end

      #
      # @since 0.3.7
      def convert_to_xml(enml)
        # remove the xml declaration and DTD
        enml = enml.split("\n")
        enml.shift(2)

        @xml = from_str(enml.join)
        self
      end
      alias to_xml convert_to_xml

      #
      # @since 0.3.5
      def prepare
        note_xml = @xml.search('en-note')

        # remove <br> tags
        note_xml.search('br').each(&:remove)
        note_xml.inner_html.to_s
      end

      #
      # @since 0.3.1
      def to_enml(hash)
        Evertils::Helper::EvernoteENML.with_list(hash)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evertils-0.3.14.1 lib/evertils/helpers/api-enml-handler.rb
evertils-0.3.14 lib/evertils/helpers/api-enml-handler.rb
evertils-0.3.13 lib/evertils/helpers/api-enml-handler.rb