Sha256: 913ebb1105c90da4954e08db3446b8bd994c56fc62bfee2dc10a7a91c4c31020

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module Vedeu
  module API

    # @see Vedeu::Composition
    class Composition < Vedeu::Composition

      # Directly write a view buffer to the terminal.
      #
      # @api public
      # @param block [Proc]
      # @return [Array] A collection of strings, each defining containing the
      #                 escape sequences and content. This data has already
      #                 been sent to the terminal to be output.
      def self.render(&block)
        fail InvalidSyntax, '`render` requires a block.' unless block_given?

        attributes = API::Composition.build({}, &block)

        Vedeu::Composition.new(attributes).interfaces.map do |interface|
          Buffers.add(interface.attributes)

          interface.name
        end.map { |name| Compositor.render(name) }
      end

      # @api public
      # @see Vedeu::API#view
      def view(name, &block)
        attributes[:interfaces] << API::Interface
          .build({ name: name, parent: self.view_attributes }, &block)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.2.1 lib/vedeu/api/composition.rb