Sha256: 4b83485b863e9b30678c569fd75a523f8cc5158d6f488dd826207497f0af6926

Contents?: true

Size: 981 Bytes

Versions: 8

Compression:

Stored size: 981 Bytes

Contents

module Vedeu

  module Renderers

    # A renderer which returns the escape sequence for each character.
    #
    # @api private
    class EscapeSequence

      # @param output [Array<Array<Vedeu::Char>>]
      # @return [String]
      def self.render(output)
        new(output).render
      end

      # @param output [Array<Array<Vedeu::Char>>]
      def initialize(output)
        @output = output
      end

      # @return [String]
      def render
        Vedeu.log(type:    :debug,
                  message: "#{self.class.name}:\n#{parsed}")

        parsed
      end

      protected

      # @!attribute [r] output
      # @return [Array<Array<Vedeu::Char>>]
      attr_reader :output

      private

      # Escapes the escape sequences.
      #
      # @return [String]
      def parsed
        @parsed ||= Array(output).flatten.map do |char|
          Esc.escape(char.to_s) + "\n"
        end.join
      end

    end # EscapeSequence

  end # Renderers

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.4.40 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.39 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.38 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.37 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.36 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.35 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.34 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.33 lib/vedeu/output/renderers/escape_sequence.rb