Sha256: 02e97bc6835891f7d9d8aa9b3cf98ae23b939a9328a82565061664e76c65195a

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

module Vedeu

  # A renderer which returns the escape sequence for each character.
  #
  class EscapeSequenceRenderer

    # @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: "Vedeu::EscapeSequenceRenderer:\n#{parsed}")

      parsed
    end

    private

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

    # 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 # EscapeSequenceRenderer

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.4.17 lib/vedeu/output/renderers/escape_sequence_renderer.rb