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
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
- #attributes ⇒ Hash<Symbol => String|Symbol> private
-
#become(klass, attributes) ⇒ Class
included
from Common
private
Converts one class into another.
-
#boolean(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating the value was a boolean.
-
#boolean?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Boolean.
- #current ⇒ Array<Vedeu::Cells::Empty> private private
-
#defaults ⇒ Hash<Symbol => NilClass|String|Symbol]
private
private
Hash<Symbol => NilClass|String|Symbol].
-
#each(&block) ⇒ Enumerator
private
Provides iteration over the buffer.
-
#escape?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
-
#falsy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered false.
- #geometry ⇒ Vedeu::Geometries::Geometry private private
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
#initialize(attributes = {}) ⇒ void
included
from Repositories::Defaults
private
Returns a new instance of the class including this module.
-
#line_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Line.
-
#numeric?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#reset! ⇒ Vedeu::Buffers::View
private
Resets the named view buffer back to its empty state.
-
#snake_case(klass) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#stream_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
#string?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#truthy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered true.
- #update(value_or_values) ⇒ Vedeu::Buffers::View private
-
#valid?(value) ⇒ Boolean
private
private
Returns a boolean indicating the value has a position attribute and is within the terminal boundary.
-
#valid_value?(value) ⇒ Boolean
private
private
Returns a boolean indicating the value has a position attribute.
-
#valid_x?(x) ⇒ Boolean
private
private
Returns a boolean indicating whether the x position of the value object is valid for this geometry.
-
#valid_y?(y) ⇒ Boolean
private
private
Returns a boolean indicating whether the y position of the value object is valid for this geometry.
- #validate(attributes) ⇒ Hash included from Repositories::Defaults private private
-
#view_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::View.
-
#write(value) ⇒ NilClass|void
private
private
Write the value into the respective cell as defined by the position attribute.
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.
60 61 62 |
# File 'lib/vedeu/buffers/view.rb', line 60 def name @name end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Common
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 a boolean indicating whether a variable is nil or empty.
#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 |
#become(klass, attributes) ⇒ Class Originally defined in module Common
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.
Converts one class into another.
#boolean(value) ⇒ Boolean Originally defined in module Common
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 a boolean indicating the value was a boolean.
#boolean?(value) ⇒ Boolean Originally defined in module Common
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 a boolean indicating whether the value is a Boolean.
#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.
65 66 67 68 69 70 71 |
# File 'lib/vedeu/buffers/view.rb', line 65 def current @current ||= Vedeu::Buffers::Empty.new(height: bordered_height, name: name, width: bordered_width, x: bx, y: by).buffer end |
#defaults ⇒ Hash<Symbol => NilClass|String|Symbol] (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 Hash<Symbol => NilClass|String|Symbol].
74 75 76 77 78 |
# File 'lib/vedeu/buffers/view.rb', line 74 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 |
#escape?(value) ⇒ Boolean Originally defined in module Common
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 a boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)
#falsy?(value) ⇒ Boolean Originally defined in module Common
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 a boolean indicating whether the value should be considered false.
#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.
81 82 83 |
# File 'lib/vedeu/buffers/view.rb', line 81 def geometry @_geometry ||= Vedeu.geometries.by_name(name) end |
#hash?(value) ⇒ Boolean Originally defined in module Common
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 a boolean indicating whether the value is a Hash.
#initialize(attributes = {}) ⇒ void Originally defined in module Repositories::Defaults
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 the class including this module.
#line_model? ⇒ Boolean Originally defined in module Common
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 a boolean indicating the model is a Views::Line.
#numeric?(value) ⇒ Boolean Originally defined in module Common
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 a boolean indicating whether the value is a Fixnum.
#present?(variable) ⇒ Boolean Originally defined in module Common
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 a boolean indicating whether a variable has a useful value.
#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 |
#snake_case(klass) ⇒ String Originally defined in module Common
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.
Converts a class name to a lowercase snake case string.
#stream_model? ⇒ Boolean Originally defined in module Common
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 a boolean indicating the model is a Views::Stream.
#string?(value) ⇒ Boolean Originally defined in module Common
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 a boolean indicating whether the value is a Fixnum.
#truthy?(value) ⇒ Boolean Originally defined in module Common
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 a boolean indicating whether the value should be considered true.
#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 |
# File 'lib/vedeu/buffers/view.rb', line 50 def update(value_or_values) Array(value_or_values).flatten.each { |value| write(value) } self end |
#valid?(value) ⇒ Boolean (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 a boolean indicating the value has a position attribute and is within the terminal boundary.
90 91 92 93 94 |
# File 'lib/vedeu/buffers/view.rb', line 90 def valid?(value) valid_value?(value) && valid_y?(value.position.y) && valid_x?(value.position.x) end |
#valid_value?(value) ⇒ Boolean (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 a boolean indicating the value has a position attribute.
101 102 103 104 |
# File 'lib/vedeu/buffers/view.rb', line 101 def valid_value?(value) value.respond_to?(:position) && value.position.is_a?(Vedeu::Geometries::Position) end |
#valid_x?(x) ⇒ Boolean (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 a boolean indicating whether the x position of the value object is valid for this geometry.
110 111 112 |
# File 'lib/vedeu/buffers/view.rb', line 110 def valid_x?(x) Vedeu::Point.valid?(value: x, min: bx, max: bxn) end |
#valid_y?(y) ⇒ Boolean (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 a boolean indicating whether the y position of the value object is valid for this geometry.
118 119 120 |
# File 'lib/vedeu/buffers/view.rb', line 118 def valid_y?(y) Vedeu::Point.valid?(value: y, min: by, max: byn) end |
#validate(attributes) ⇒ Hash (private) Originally defined in module Repositories::Defaults
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.
#view_model? ⇒ Boolean Originally defined in module Common
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 a boolean indicating the model is a Views::View.
#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.
127 128 129 |
# File 'lib/vedeu/buffers/view.rb', line 127 def write(value) current[value.position.y][value.position.x] = value if valid?(value) end |