Sha256: 5341b03137cf4731dba5de0e6f4614c9bb788bc8699b4b92f10abcc128cf06e5

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module Vedeu

  module API

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

      # Directly write a view buffer to the terminal.
      #
      # @param block [Proc]
      # @raise [InvalidSyntax] When the required block is not given.
      # @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| Vedeu::Refresh.by_name(name) }
      end

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

    end # Composition

  end # API

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

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