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.
-
#border ⇒ Object
private
private
Returns the border for the interface.
-
#bottom ⇒ String
private
private
Renders the bottom border for the interface.
- #build(value, type = :border, iy = 0, ix = 0) ⇒ Vedeu::Views::Char private private
-
#build_bottom ⇒ Array<Vedeu::Views::Char>
private
private
Creates a bottom border character.
-
#build_bottom_left ⇒ Vedeu::Views::Char
private
private
Creates the bottom left border character.
-
#build_bottom_right ⇒ Vedeu::Views::Char
private
private
Creates the bottom right border character.
- #build_horizontal(position, y_coordinate) ⇒ Array<Vedeu::Views::Char> private private
-
#build_top ⇒ Array<Vedeu::Views::Char>
private
private
Creates a top border character.
-
#build_top_left ⇒ Vedeu::Views::Char
private
private
Creates the top left border character.
-
#build_top_right ⇒ Vedeu::Views::Char
private
private
Creates the top right border character.
- #by_name ⇒ Array<Array<Vedeu::Views::Char>> (also: #render) private
-
#captionbar ⇒ Array<Vedeu::Views::Char>
private
private
Overwrite the border from #build_horizontal on the bottom border to include the caption if given.
-
#demodulize(klass) ⇒ String
included
from Common
private
Removes the module part from the expression in the string.
-
#geometry ⇒ Object
private
private
Returns the geometry for the interface.
-
#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(iy = 0) ⇒ String
private
private
Renders the left border for the interface.
- #output ⇒ Array<Array<Vedeu::Views::Char>> private private
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#right(iy = 0) ⇒ String
private
private
Renders the right border for the interface.
-
#snake_case(name) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#titlebar ⇒ Array<Vedeu::Views::Char>
private
private
Overwrite the border from #build_horizontal on the top border to include the title if given.
-
#top ⇒ String
private
private
Renders the top border for the interface.
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.
62 63 64 |
# File 'lib/vedeu/borders/refresh.rb', line 62 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.
76 77 78 |
# File 'lib/vedeu/borders/refresh.rb', line 76 def name @name end |
Class Method Details
.by_name(name = Vedeu.focus) ⇒ Array<Array<Vedeu::Views::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.
51 52 53 54 55 |
# File 'lib/vedeu/borders/refresh.rb', line 51 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.
#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.
83 84 85 |
# File 'lib/vedeu/borders/refresh.rb', line 83 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.
163 164 165 166 167 |
# File 'lib/vedeu/borders/refresh.rb', line 163 def bottom return [] unless bottom? [build_bottom_left, , build_bottom_right].compact end |
#build(value, type = :border, iy = 0, ix = 0) ⇒ Vedeu::Views::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 |
# File 'lib/vedeu/borders/refresh.rb', line 103 def build(value, type = :border, iy = 0, ix = 0) Vedeu::Views::Char.new(value: value, parent: interface, colour: colour, name: name, style: style, position: [iy, ix], border: type) end |
#build_bottom ⇒ Array<Vedeu::Views::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.
Creates a bottom border character.
137 138 139 |
# File 'lib/vedeu/borders/refresh.rb', line 137 def build_bottom build_horizontal(:bottom_horizontal, yn) end |
#build_bottom_left ⇒ Vedeu::Views::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.
Creates the bottom left border character.
116 117 118 |
# File 'lib/vedeu/borders/refresh.rb', line 116 def build_bottom_left build(bottom_left, :bottom_left, yn, x) if left? end |
#build_bottom_right ⇒ Vedeu::Views::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.
Creates the bottom right border character.
123 124 125 |
# File 'lib/vedeu/borders/refresh.rb', line 123 def build_bottom_right build(bottom_right, :bottom_right, yn, xn) if right? end |
#build_horizontal(position, y_coordinate) ⇒ Array<Vedeu::Views::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.
180 181 182 183 184 |
# File 'lib/vedeu/borders/refresh.rb', line 180 def build_horizontal(position, y_coordinate) Array.new(width) do |ix| build(horizontal, position, y_coordinate, (bx + ix)) end end |
#build_top ⇒ Array<Vedeu::Views::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.
Creates a top border character.
130 131 132 |
# File 'lib/vedeu/borders/refresh.rb', line 130 def build_top build_horizontal(:bottom_horizontal, y) end |
#build_top_left ⇒ Vedeu::Views::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.
Creates the top left border character.
144 145 146 |
# File 'lib/vedeu/borders/refresh.rb', line 144 def build_top_left build(top_left, :top_left, y, x) if left? end |
#build_top_right ⇒ Vedeu::Views::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.
Creates the top right border character.
151 152 153 |
# File 'lib/vedeu/borders/refresh.rb', line 151 def build_top_right build(top_right, :top_right, y, xn) if right? end |
#by_name ⇒ Array<Array<Vedeu::Views::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.
67 68 69 |
# File 'lib/vedeu/borders/refresh.rb', line 67 def by_name Vedeu.render_output(output) if enabled? && visible? end |
#captionbar ⇒ Array<Vedeu::Views::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.
Overwrite the border from #build_horizontal on the bottom border to include the caption if given.
235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/vedeu/borders/refresh.rb', line 235 def return build_bottom if caption.empty? caption_starts_at = (width - caption.size) - 2 caption_index = 0 build_bottom.each_with_index do |char, index| next if index <= caption_starts_at || index > (width - 2) char.border = nil char.value = caption.characters[caption_index] caption_index += 1 end end |
#demodulize(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.
Removes the module part from the expression in the string.
#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.
172 173 174 |
# File 'lib/vedeu/borders/refresh.rb', line 172 def geometry Vedeu.geometries.by_name(name) end |
#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.
192 193 194 |
# File 'lib/vedeu/borders/refresh.rb', line 192 def interface @interface ||= Vedeu.interfaces.by_name(name) end |
#left(iy = 0) ⇒ 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.
Renders the left border for the interface.
201 202 203 204 205 |
# File 'lib/vedeu/borders/refresh.rb', line 201 def left(iy = 0) return [] unless left? build(vertical, :left_vertical, (by + iy), x) end |
#output ⇒ Array<Array<Vedeu::Views::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.
88 89 90 91 92 93 94 95 96 |
# File 'lib/vedeu/borders/refresh.rb', line 88 def output Vedeu.timer("Drawing border: '#{name}'".freeze) do out = [top, bottom] height.times { |y| out << [left(y), right(y)] } out.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(iy = 0) ⇒ 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.
Renders the right border for the interface.
211 212 213 214 215 |
# File 'lib/vedeu/borders/refresh.rb', line 211 def right(iy = 0) return [] unless right? build(vertical, :right_vertical, (by + iy), xn) end |
#snake_case(name) ⇒ 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.
#titlebar ⇒ Array<Vedeu::Views::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.
Overwrite the border from #build_horizontal on the top border to include the title if given.
254 255 256 257 258 259 260 261 262 263 |
# File 'lib/vedeu/borders/refresh.rb', line 254 def return build_top if title.empty? build_top.each_with_index do |char, index| next if index == 0 || index > title.size char.border = nil char.value = title.characters[index - 1] end 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.
225 226 227 228 229 |
# File 'lib/vedeu/borders/refresh.rb', line 225 def top return [] unless top? [build_top_left, , build_top_right].compact end |