Sha256: 1fe94850d3e84d80c1f50e9c09d0e725f98b6a5a0a6c226a99543aa4580dabeb

Contents?: true

Size: 905 Bytes

Versions: 17

Compression:

Stored size: 905 Bytes

Contents

# frozen_string_literal: true
require 'mustermann/visualizer/renderer/generic'

module Mustermann
  module Visualizer
    # @!visibility private
    module Renderer
      # Generates a s-expression like string.
      # @!visibility private
      class Sexp < Generic
        # @!visibility private
        def render
          @inspect = false
          super.gsub(/ ?\)( \))*/) { |s| s.gsub(' ', '') }.strip
        end


        # @!visibility private
        def pre(type)
          "(#{type} " if type != :pattern
        end

        # @!visibility private
        def escape_string(input)
          inspect = input.inspect
          input   = inspect if inspect != "\"#{input}\""
          input   = inspect if input =~ /[\s\"\'\(\)]/
          input + " "
        end

        # @!visibility private
        def post(type)
          ") " if type != :pattern
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
mustermann-contrib-3.0.3 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-3.0.2 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-3.0.1 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-3.0.0 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-2.0.2 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-2.0.1 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-2.0.0 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-1.1.2 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-1.1.1 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-1.1.0 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-1.0.3 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-1.0.2 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-1.0.2.rc2 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-1.0.2.rc1 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-1.0.2.rc1 mustermann-contrib/lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-1.0.1 lib/mustermann/visualizer/renderer/sexp.rb
mustermann-contrib-1.0.0 lib/mustermann/visualizer/renderer/sexp.rb