Sha256: d81f661af79363efaa39e7a3e250f1e0f05fd7dcef0dcfbb6ecdae7b85c80c95

Contents?: true

Size: 692 Bytes

Versions: 2

Compression:

Stored size: 692 Bytes

Contents

# frozen_string_literal: true

require 'ox'

module ArticleFixtureGen
  module Data
    # Render an Ox::Element instance as HTML.
    class MarkupFromNode
      DEFAULT_OPTIONS = { indent: -1 }.freeze

      def self.call(node, options = DEFAULT_OPTIONS)
        Ox.dump(node, options)
      end
    end # class ArticleFixtureGen::Data::MarkupFromNode

    # Convert an HTML string to an Ox::Element.
    # NOTE: HTML *must* comprise a single outermost element, that may have an
    #       arbitrary number of nested elements within it.
    class NodeFromMarkup
      def self.call(markup)
        Ox.parse(markup)
      end
    end # class ArticleFixtureGen::Data::NodeFromMarkup
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
article_fixture_gen-0.1.2 lib/article_fixture_gen/data/node_markup.rb
article_fixture_gen-0.1.1 lib/article_fixture_gen/data/node_markup.rb