Sha256: 341af66ca28cee12e4234728757311821e4d9dd6d9a8cec53e45faea01902e7b

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module Vedeu

  # Classes within the Output namespace handle various aspects of
  # rendering content.
  #
  module Output

    # Sends the output to the renderers.
    #
    class Output

      # Writes output to the defined renderers.
      #
      # @return [Array|String]
      # @see #initialize
      def self.render(output)
        new(output).render
      end

      # Return a new instance of Vedeu::Output::Output.
      #
      # @param output [Array<Array<Vedeu::Views::Char>>]
      # @return [Vedeu::Output::Output]
      def initialize(output)
        @output = output
      end

      # Send the view to the renderers.
      #
      # @return [Array]
      def render
        return render_terminal_buffer unless output.is_a?(Vedeu::Models::Escape)

        Vedeu::Output::Direct.write(value: output.value,
                                    x:     output.position.x,
                                    y:     output.position.y)
      end

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

      # @return [Array]
      def render_terminal_buffer
        Vedeu::Terminal::Buffer.write(output).render
      end

    end # Output

  end # Output

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.6.13 lib/vedeu/output/output.rb