Sha256: bfae6b2e9d63b680c0ff9d36d5b64084c111676edeac81cd1c1ce4fd0afade0d

Contents?: true

Size: 760 Bytes

Versions: 5

Compression:

Stored size: 760 Bytes

Contents

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

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

        @xml = Nokogiri::XML::DocumentFragment.parse(enml.join)
        self
      end

      #
      # @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

5 entries across 5 versions & 1 rubygems

Version Path
evertils-0.3.12 lib/evertils/helpers/api-enml-handler.rb
evertils-0.3.11 lib/evertils/helpers/api-enml-handler.rb
evertils-0.3.10 lib/evertils/helpers/api-enml-handler.rb
evertils-0.3.9 lib/evertils/helpers/api-enml-handler.rb
evertils-0.3.8 lib/evertils/helpers/api-enml-handler.rb