Class: Vedeu::Buffers::View Private
- Inherits:
-
Object
- Object
- Vedeu::Buffers::View
- Extended by:
- Forwardable
- Includes:
- Enumerable, Repositories::Defaults
- Defined in:
- lib/vedeu/buffers/view.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.
Allow the creation of individual named buffers for views.
Instance Attribute Summary collapse
- #name ⇒ String|Symbol readonly protected private
Instance Method Summary collapse
- #attributes ⇒ Hash<Symbol => String|Symbol> private
- #column(value) ⇒ Fixnum private private
- #current ⇒ Array<Vedeu::Cells::Empty> private private
-
#defaults ⇒ Hash<Symbol => void>
private
private
The default options/attributes for a new instance of this class.
-
#each(&block) ⇒ Enumerator
private
Provides iteration over the buffer.
- #geometry ⇒ Vedeu::Geometries::Geometry private private
-
#reset! ⇒ Vedeu::Buffers::View
private
Resets the named view buffer back to its empty state.
- #row(value) ⇒ Fixnum private private
- #update(value_or_values) ⇒ Vedeu::Buffers::View private
-
#write(value) ⇒ NilClass|void
private
private
Write the value into the respective cell as defined by the position attribute.
Methods included from Repositories::Defaults
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
Instance Attribute Details
#name ⇒ String|Symbol (readonly, protected)
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.
62 63 64 |
# File 'lib/vedeu/buffers/view.rb', line 62 def name @name end |
Instance Method Details
#attributes ⇒ Hash<Symbol => String|Symbol>
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.
26 27 28 29 30 |
# File 'lib/vedeu/buffers/view.rb', line 26 def attributes { name: name, } end |
#column(value) ⇒ Fixnum (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.
68 69 70 |
# File 'lib/vedeu/buffers/view.rb', line 68 def column(value) Vedeu::Point.coerce(value: value.position.x, min: bx, max: bxn).value end |
#current ⇒ Array<Vedeu::Cells::Empty> (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.
73 74 75 76 77 78 79 |
# File 'lib/vedeu/buffers/view.rb', line 73 def current @current ||= Vedeu::Buffers::Empty.new(height: bordered_height, name: name, width: bordered_width, x: bx, y: by).buffer 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.
The default options/attributes for a new instance of this class.
82 83 84 85 86 |
# File 'lib/vedeu/buffers/view.rb', line 82 def defaults { name: nil, } end |
#each(&block) ⇒ Enumerator
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.
Provides iteration over the buffer.
36 37 38 |
# File 'lib/vedeu/buffers/view.rb', line 36 def each(&block) current.each(&block) end |
#geometry ⇒ Vedeu::Geometries::Geometry (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.
89 90 91 |
# File 'lib/vedeu/buffers/view.rb', line 89 def geometry @_geometry ||= Vedeu.geometries.by_name(name) end |
#reset! ⇒ Vedeu::Buffers::View
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.
Resets the named view buffer back to its empty state.
43 44 45 |
# File 'lib/vedeu/buffers/view.rb', line 43 def reset! Vedeu::Buffers::View.new(attributes) end |
#row(value) ⇒ Fixnum (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.
95 96 97 |
# File 'lib/vedeu/buffers/view.rb', line 95 def row(value) Vedeu::Point.coerce(value: value.position.y, min: by, max: byn).value end |
#update(value_or_values) ⇒ Vedeu::Buffers::View
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.
50 51 52 53 54 55 56 |
# File 'lib/vedeu/buffers/view.rb', line 50 def update(value_or_values) Array(value_or_values).flatten.each do |value| write(value) if positionable?(value) end self end |
#write(value) ⇒ NilClass|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.
Write the value into the respective cell as defined by the position attribute.
104 105 106 |
# File 'lib/vedeu/buffers/view.rb', line 104 def write(value) current[row(value)][column(value)] = value end |