Sha256: 31330b877b5cc5c893991b555e1df9b9b80b67f62cc335b4eee2b12d67ce45e7

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Buffers

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

      include Vedeu::Repositories::Defaults

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

      # @!attribute [r] x
      # @return [Fixnum]
      attr_reader :x

      # @!attribute [r] y
      # @return [Fixnum]
      attr_reader :y

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

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

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

      private

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

      # @return [Array<Array<Vedeu::Cells::Empty>>]
      def empty
        Array.new(height) do
          Array.new(width) do
            Vedeu::Cells::Empty.new(name: name)
          end
        end
      end

    end # Empty

  end # Buffers

end # Vedeu

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
vedeu-0.8.32 lib/vedeu/buffers/empty.rb
vedeu-0.8.31 lib/vedeu/buffers/empty.rb
vedeu-0.8.30 lib/vedeu/buffers/empty.rb
vedeu-0.8.29 lib/vedeu/buffers/empty.rb
vedeu-0.8.28 lib/vedeu/buffers/empty.rb
vedeu-0.8.27 lib/vedeu/buffers/empty.rb
vedeu-0.8.26 lib/vedeu/buffers/empty.rb
vedeu-0.8.25 lib/vedeu/buffers/empty.rb
vedeu-0.8.24 lib/vedeu/buffers/empty.rb