Sha256: 9a4a1fa1cb189e1ab383192bfc383f2d939ca9a70a59545a8d2d9472764fabaa

Contents?: true

Size: 477 Bytes

Versions: 6

Compression:

Stored size: 477 Bytes

Contents

require_relative './base_node_renderer'

module RichTextRenderer
  # Catch-all renderer for missing node types
  class NullRenderer < BaseNodeRenderer
    # Will raise an exception indicating the missing node type.
    def render(node)
      fail "No renderer defined for '#{node_type(node)}' nodes"
    end

    private

    def node_type(node)
      return node['nodeType'] if node.key?('nodeType')
      return node['type'] if node.key?('type')
      node
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rich_text_renderer-0.3.0 lib/rich_text_renderer/null_renderer.rb
rich_text_renderer-0.2.3 lib/rich_text_renderer/null_renderer.rb
rich_text_renderer-0.2.2 lib/rich_text_renderer/null_renderer.rb
rich_text_renderer-0.2.1 lib/rich_text_renderer/null_renderer.rb
rich_text_renderer-0.2.0 lib/rich_text_renderer/null_renderer.rb
rich_text_renderer-0.1.0 lib/rich_text_renderer/null_renderer.rb