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.
-
#render_caption ⇒ Vedeu::Borders::Caption
private
private
An optional caption for when the bottom border is to be shown.
-
#render_title ⇒ Vedeu::Borders::Title
private
private
An optional title for when the top border is to be shown.
-
#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.
64 65 66 |
# File 'lib/vedeu/borders/refresh.rb', line 64 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.
78 79 80 |
# File 'lib/vedeu/borders/refresh.rb', line 78 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.
53 54 55 56 57 |
# File 'lib/vedeu/borders/refresh.rb', line 53 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.
85 86 87 |
# File 'lib/vedeu/borders/refresh.rb', line 85 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.
177 178 179 180 181 |
# File 'lib/vedeu/borders/refresh.rb', line 177 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.
117 118 119 120 121 122 123 124 125 |
# File 'lib/vedeu/borders/refresh.rb', line 117 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.
151 152 153 |
# File 'lib/vedeu/borders/refresh.rb', line 151 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.
130 131 132 |
# File 'lib/vedeu/borders/refresh.rb', line 130 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.
137 138 139 |
# File 'lib/vedeu/borders/refresh.rb', line 137 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.
194 195 196 197 198 |
# File 'lib/vedeu/borders/refresh.rb', line 194 def build_horizontal(position, y_coordinate) Array.new(bordered_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.
144 145 146 |
# File 'lib/vedeu/borders/refresh.rb', line 144 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.
158 159 160 |
# File 'lib/vedeu/borders/refresh.rb', line 158 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.
165 166 167 |
# File 'lib/vedeu/borders/refresh.rb', line 165 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.
69 70 71 |
# File 'lib/vedeu/borders/refresh.rb', line 69 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.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/vedeu/borders/refresh.rb', line 249 def return build_bottom if render_caption.empty? caption_starts_at = (width - render_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 = render_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.
186 187 188 |
# File 'lib/vedeu/borders/refresh.rb', line 186 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.
206 207 208 |
# File 'lib/vedeu/borders/refresh.rb', line 206 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.
215 216 217 218 219 |
# File 'lib/vedeu/borders/refresh.rb', line 215 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.
90 91 92 93 94 95 96 97 98 |
# File 'lib/vedeu/borders/refresh.rb', line 90 def output Vedeu.timer("Drawing border: '#{name}'".freeze) do out = [top, bottom] bordered_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.
#render_caption ⇒ Vedeu::Borders::Caption (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 An optional caption for when the bottom border is to be shown.
102 103 104 |
# File 'lib/vedeu/borders/refresh.rb', line 102 def render_caption @_caption ||= Vedeu::Borders::Caption.coerce(caption, width) end |
#render_title ⇒ Vedeu::Borders::Title (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 An optional title for when the top border is to be shown.
108 109 110 |
# File 'lib/vedeu/borders/refresh.rb', line 108 def render_title @_title ||= Vedeu::Borders::Title.coerce(title, width) end |
#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.
225 226 227 228 229 |
# File 'lib/vedeu/borders/refresh.rb', line 225 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.
268 269 270 271 272 273 274 275 276 277 |
# File 'lib/vedeu/borders/refresh.rb', line 268 def return build_top if render_title.empty? build_top.each_with_index do |char, index| next if index == 0 || index > render_title.size char.border = nil char.value = render_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.
239 240 241 242 243 |
# File 'lib/vedeu/borders/refresh.rb', line 239 def top return [] unless top? [build_top_left, , build_top_right].compact end |