Class: Vedeu::Buffers::Empty Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/buffers/empty.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Provides a grid of Vedeu::Models::Cell objects at the given height and width.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Vedeu::Buffers::Empty

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

If a particular key is missing from the attributes parameter, then it is added with the respective value from #defaults.

Returns a new instance of Vedeu::Buffers::Empty.

Options Hash (attributes):

  • name (NilClass|String|Symbol)
  • height (Fixnum)
  • width (Fixnum)


28
29
30
31
32
# File 'lib/vedeu/buffers/empty.rb', line 28

def initialize(attributes = {})
  defaults.merge!(attributes).each do |key, value|
    instance_variable_set("@#{key}", value || defaults.fetch(key))
  end
end

Instance Attribute Details

#nameNilClass|String|Symbol (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
# File 'lib/vedeu/buffers/empty.rb', line 13

def name
  @name
end

Instance Method Details

#bufferArray<Array<Vedeu::Models::Cell>>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
# File 'lib/vedeu/buffers/empty.rb', line 35

def buffer
  Array.new(width) do |y|
    Array.new(height) do |x|
      Vedeu::Models::Cell.new(name: name, position: [y, x])
    end
  end
end

#defaultsHash<Symbol => void> (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the default options/attributes for this class.



66
67
68
69
70
71
72
# File 'lib/vedeu/buffers/empty.rb', line 66

def defaults
  {
    height: Vedeu.height,
    name:   nil,
    width:  Vedeu.width,
  }
end

#heightFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

We add 1 to both the width and height as terminal screens are 1-indexed.



48
49
50
# File 'lib/vedeu/buffers/empty.rb', line 48

def height
  @height + 1
end

#widthFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

We add 1 to both the width and height as terminal screens are 1-indexed.



57
58
59
# File 'lib/vedeu/buffers/empty.rb', line 57

def width
  @width + 1
end