Sha256: d7cf4f8e125ea5aacd539aa45a6f2600c264bef968890fa62ea5f4ef07240c1d

Contents?: true

Size: 559 Bytes

Versions: 1

Compression:

Stored size: 559 Bytes

Contents

require 'nokogiri'

module Rocx
  module Parts
    class BasePart
      include ::Nokogiri

      def build_xml
        XML::Builder.new(encoding: "utf-8") { |xml| yield xml }.to_xml
      end

      def build_standalone_xml
        xml = Nokogiri::XML("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>")
        XML::Builder.with(xml) { |xml| yield xml }.to_xml
      end

      def read
        raise NotImplementedError
      end

    protected

      def strip_whitespace(xml)
        xml.lines.map(&:strip).join
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rocx-0.5.6 lib/rocx/parts/base_part.rb