Sha256: c388ff7db449fe42fa6a4e1f1278ebff41a453c976b2fe5087ce96b10c316dec

Contents?: true

Size: 956 Bytes

Versions: 14

Compression:

Stored size: 956 Bytes

Contents

module Vedeu

  module Renderers

    # A renderer which returns the escape sequence for each character.
    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

14 entries across 14 versions & 1 rubygems

Version Path
vedeu-0.4.32 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.31 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.30 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.29 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.28 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.27 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.26 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.25 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.24 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.23 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.22 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.21 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.20 lib/vedeu/output/renderers/escape_sequence.rb
vedeu-0.4.19 lib/vedeu/output/renderers/escape_sequence.rb