Sha256: 05932a5c23d27d6f6357d1f78b24bddead447d2efc4890df34e8bd3c676bfe47

Contents?: true

Size: 960 Bytes

Versions: 10

Compression:

Stored size: 960 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

      # Returns a new instance of Vedeu::Renderers::EscapeSequence.
      #
      # @param output [Array<Array<Vedeu::Char>>]
      def initialize(output)
        @output = output
      end

      # @return [String]
      def render
        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

10 entries across 10 versions & 1 rubygems

Version Path
vedeu-0.4.50 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.49 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.48 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.47 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.46 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.45 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.44 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.43 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.42 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.41 lib/vedeu/output/renderers/escape_sequence.rb