Sha256: 7764c6b644df5310be66bccc1184b0ae19a7830a1f270cb2a36a225bcc86681c

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Buffers

    # Provides a grid of Vedeu::Cells::Clear objects at the given
    # height and width.
    #
    # @api private
    #
    class Clear

      include Vedeu::Repositories::Defaults

      # @!attribute [r] name
      # @return [NilClass|String|Symbol]
      attr_reader :name

      # @return [Array<Array<Vedeu::Cells::Clear>>]
      def buffer
        @buffer ||= clear
      end

      # @return [Fixnum]
      def height
        @height + 1
      end

      # @return [Fixnum]
      def width
        @width + 1
      end

      private

      # @macro interface_by_name
      def interface
        @_interface ||= Vedeu.interfaces.by_name(name)
      end

      # @macro defaults_method
      def defaults
        {
          height: Vedeu.height,
          name:   nil,
          width:  Vedeu.width,
        }
      end

      # @return [Array<Array<Vedeu::Cells::Clear>>]
      def clear
        Array.new(height) do
          Array.new(width) do
            Vedeu::Cells::Clear.new(colour: interface.colour, name: name)
          end
        end
      end

    end # Clear

  end # Buffers

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.8.32 lib/vedeu/buffers/clear.rb
vedeu-0.8.31 lib/vedeu/buffers/clear.rb