Class: Vedeu::Borders::Refresh Private
- Inherits:
-
Object
- Object
- Vedeu::Borders::Refresh
- Extended by:
- Forwardable
- Includes:
- Common
- Defined in:
- lib/vedeu/borders/refresh.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.
Renders and refreshes the named border.
Instance Attribute Summary collapse
- #name ⇒ String|Symbol readonly protected private
Class Method Summary collapse
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 => void> private 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.
-
#border ⇒ Object
private
private
Returns the border for the interface.
-
#bottom ⇒ String
private
private
Renders the bottom border for the interface.
-
#build_collection(size, &block) ⇒ Array<void>
private
private
Build a collection with the given size of objects given within the block.
- #by_name ⇒ Array<Array<Vedeu::Cells::Char>> (also: #render) private
-
#captionbar ⇒ Object
private
private
An optional caption for when the bottom border is to be shown.
-
#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 ⇒ Object
private
private
Returns the geometry for the interface.
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
#initialize(name = Vedeu.focus) ⇒ Vedeu::Borders::Refresh
constructor
private
Returns a new instance of Vedeu::Borders::Refresh.
-
#interface ⇒ Object
(also: #parent)
private
private
Returns the interface by name.
-
#left ⇒ Array<void>
private
private
Renders the left border for the interface.
-
#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.
- #output ⇒ Array<Array<Vedeu::Cells::Char>> private private
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#right ⇒ Array<void>
private
private
Renders the right border for the interface.
-
#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.
-
#titlebar ⇒ Array<Vedeu::Cells::Horizontal|Vedeu::Cells::Char>
private
private
An optional title for when the top border is to be shown.
-
#top ⇒ String
private
private
Renders the top border for the interface.
-
#truthy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered true.
-
#view_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::View.
Constructor Details
#initialize(name = Vedeu.focus) ⇒ Vedeu::Borders::Refresh
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 new instance of Vedeu::Borders::Refresh.
68 69 70 |
# File 'lib/vedeu/borders/refresh.rb', line 68 def initialize(name = Vedeu.focus) @name = present?(name) ? name : Vedeu.focus end |
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.
82 83 84 |
# File 'lib/vedeu/borders/refresh.rb', line 82 def name @name end |
Class Method Details
.by_name(name = Vedeu.focus) ⇒ Array<Array<Vedeu::Cells::Char>>
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.
57 58 59 60 61 |
# File 'lib/vedeu/borders/refresh.rb', line 57 def self.by_name(name = Vedeu.focus) name || Vedeu.focus new(name).by_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 => 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.
87 88 89 90 91 92 93 |
# File 'lib/vedeu/borders/refresh.rb', line 87 def attributes { colour: colour, name: name, style: style, } 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.
#border ⇒ Object (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 border for the interface.
98 99 100 |
# File 'lib/vedeu/borders/refresh.rb', line 98 def border @border ||= Vedeu.borders.by_name(name) end |
#bottom ⇒ String (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.
If a caption has been specified, then the bottom border will include this caption unless the size of the interface is smaller than the padded caption length.
Renders the bottom border for the interface.
122 123 124 |
# File 'lib/vedeu/borders/refresh.rb', line 122 def bottom [(bottom_left if left?), , (bottom_right if right?)].compact end |
#build_collection(size, &block) ⇒ Array<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.
Build a collection with the given size of objects given within the block.
214 215 216 |
# File 'lib/vedeu/borders/refresh.rb', line 214 def build_collection(size, &block) Array.new(size) { |e| yield(e) } end |
#by_name ⇒ Array<Array<Vedeu::Cells::Char>> Also known as: render
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 |
# File 'lib/vedeu/borders/refresh.rb', line 73 def by_name Vedeu.render_output(output) if enabled? && visible? end |
#captionbar ⇒ Object (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.
An optional caption for when the bottom border is to be shown.
181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/vedeu/borders/refresh.rb', line 181 def characters = build_collection(bordered_width) do |ix| cell = bottom_horizontal.dup cell.position = [yn, bx + ix] cell end return characters unless present?(caption) Vedeu::Borders::Caption.render(name, caption, characters) 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 ⇒ Object (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 geometry for the interface.
129 130 131 |
# File 'lib/vedeu/borders/refresh.rb', line 129 def 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.
#interface ⇒ Object (private) Also known as: parent
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 parent of a border is always an interface.
Returns the interface by name.
139 140 141 |
# File 'lib/vedeu/borders/refresh.rb', line 139 def interface @interface ||= Vedeu.interfaces.by_name(name) end |
#left ⇒ Array<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.
Renders the left border for the interface.
147 148 149 150 151 152 153 |
# File 'lib/vedeu/borders/refresh.rb', line 147 def left build_collection(bordered_height) do |iy| cell = left_vertical.dup cell.position = [by + iy, x] cell end end |
#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.
#output ⇒ Array<Array<Vedeu::Cells::Char>> (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.
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/vedeu/borders/refresh.rb', line 103 def output Vedeu.timer("Drawing border: '#{name}'") do [ (top if top?), (left if left?), (right if right?), (bottom if bottom?), ].flatten end end |
#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.
#right ⇒ Array<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.
Renders the right border for the interface.
158 159 160 161 162 163 164 |
# File 'lib/vedeu/borders/refresh.rb', line 158 def right build_collection(bordered_height) do |iy| cell = right_vertical.dup cell.position = [by + iy, xn] cell end 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.
#titlebar ⇒ Array<Vedeu::Cells::Horizontal|Vedeu::Cells::Char> (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.
An optional title for when the top border is to be shown.
196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/vedeu/borders/refresh.rb', line 196 def characters = build_collection(bordered_width) do |ix| cell = top_horizontal.dup cell.position = [y, bx + ix] cell end return characters unless present?(title) Vedeu::Borders::Title.render(name, title, characters) end |
#top ⇒ String (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.
If a title has been specified, then the top border will include this title unless the size of the interface is smaller than the padded title length.
Renders the top border for the interface.
174 175 176 |
# File 'lib/vedeu/borders/refresh.rb', line 174 def top [(top_left if left?), , (top_right if right?)].compact end |
#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.
#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.