Class: Vedeu::Buffers::Empty Private
- Inherits:
-
Object
- Object
- Vedeu::Buffers::Empty
- 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
- #name ⇒ NilClass|String|Symbol readonly private
Instance Method Summary collapse
- #buffer ⇒ Array<Array<Vedeu::Models::Cell>> private
-
#defaults ⇒ Hash<Symbol => void>
private
private
Returns the default options/attributes for this class.
- #height ⇒ Fixnum private
-
#initialize(attributes = {}) ⇒ Vedeu::Buffers::Empty
constructor
private
Returns a new instance of Vedeu::Buffers::Empty.
- #width ⇒ Fixnum private
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.
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.
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
#name ⇒ NilClass|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
#buffer ⇒ Array<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 |
#defaults ⇒ Hash<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 |
#height ⇒ Fixnum
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.
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 |
#width ⇒ Fixnum
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.
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 |