Sha256: a80773e4a4343a740f885fba921b55fef1e01e4e79cff1ce7bf6b447a30af0fa

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true
require 'mustermann/visualizer/highlight'
require 'mustermann/visualizer/tree_renderer'
require 'mustermann/visualizer/pattern_extension'

module Mustermann
  # Namespace for Mustermann visualization logic.
  module Visualizer
    extend self

    # @example creating a highlight object
    #   require 'mustermann/visualizer'
    #
    #   pattern   = Mustermann.new('/:name')
    #   highlight = Mustermann::Visualizer.highlight(pattern)
    #
    #   puts highlight.to_ansi
    #
    # @return [Mustermann::Visualizer::Highlight] highlight object for given pattern
    # @param (see Mustermann::Visualizer::Highlight#initialize)
    def highlight(pattern, **options)
      Highlight.new(pattern, **options)
    end

    # @example creating a tree object
    #   require 'mustermann/visualizer'
    #
    #   pattern = Mustermann.new('/:name')
    #   tree    = Mustermann::Visualizer.tree(pattern)
    #
    #   puts highlight.to_s
    #
    # @return [Mustermann::Visualizer::Tree] tree object for given pattern
    def tree(pattern, **options)
      TreeRenderer.render(pattern, **options)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mustermann-contrib-3.0.3 lib/mustermann/visualizer.rb
mustermann-contrib-3.0.2 lib/mustermann/visualizer.rb
mustermann-contrib-3.0.1 lib/mustermann/visualizer.rb
mustermann-contrib-3.0.0 lib/mustermann/visualizer.rb
mustermann-contrib-2.0.2 lib/mustermann/visualizer.rb
mustermann-contrib-2.0.1 lib/mustermann/visualizer.rb
mustermann-contrib-2.0.0 lib/mustermann/visualizer.rb