Class: Vedeu::Borders::Border
- Inherits:
-
Object
- Object
- Vedeu::Borders::Border
- Extended by:
- Forwardable
- Includes:
- Presentation, Repositories::Model
- Defined in:
- lib/vedeu/borders/border.rb
Overview
Refer to UTF-8 U+2500 to U+257F for border characters. More details can be found at: en.wikipedia.org/wiki/Box-drawing_character
Provides the mechanism to decorate an interface with a border on all edges, or specific edges. The characters which are used for the border parts (e.g. the corners, verticals and horizontals) can be customised as can the colours and styles.
More information can be found at: Borders
Instance Attribute Summary collapse
-
#bottom_horizontal ⇒ Vedeu::Cells::BottomHorizontal
Return the client application configured bottom horizontal cell character, or the default if not set.
-
#bottom_left ⇒ Vedeu::Cells::BottomLeft
Return the client application configured bottom left cell character, or the default if not set.
-
#bottom_right ⇒ Vedeu::Cells::BottomRight
Return the client application configured bottom right cell character, or the default if not set.
-
#caption ⇒ String
An optional caption for when the bottom border is to be shown.
-
#enabled ⇒ Boolean
(also: #enabled?)
Determines whether this border should be rendered.
-
#horizontal ⇒ String
The character to be used for the horizontal side border.
-
#left_vertical ⇒ Vedeu::Cells::LeftVertical
Return the client application configured left vertical cell character, or the default if not set.
-
#name ⇒ String|Symbol
readonly
Associates the border with the same-named interface/view.
-
#parent ⇒ Vedeu::Interfaces::Interface|NilClass
readonly
The interface/ view associated with this border.
- #repository ⇒ Vedeu::Repositories::Repository included from Repositories::Model
-
#right_vertical ⇒ Vedeu::Cells::RightVertical
Return the client application configured right vertical cell character, or the default if not set.
-
#show_bottom ⇒ Boolean
(also: #bottom?)
Determines whether the bottom border should be shown.
-
#show_left ⇒ Boolean
(also: #left?)
Determines whether the left border should be shown.
-
#show_right ⇒ Boolean
(also: #right?)
Determines whether the right border should be shown.
-
#show_top ⇒ Boolean
(also: #top?)
Determines whether the top border should be shown.
-
#title ⇒ String
An optional title for when the top border is to be shown.
-
#top_horizontal ⇒ Vedeu::Cells::TopHorizontal
Return the client application configured top horizontal cell character, or the default if not set.
-
#top_left ⇒ Vedeu::Cells::TopLeft
Return the client application configured top left cell character, or the default if not set.
-
#top_right ⇒ Vedeu::Cells::TopRight
Return the client application configured top right cell character, or the default if not set.
-
#vertical ⇒ String
The character to be used for the vertical side border.
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 => Boolean|Hash|NilClass|String|Symbol| Vedeu::Borders::Repository|Vedeu::Presentation::Style>
-
#background ⇒ Vedeu::Colours::Background
included
from Presentation::Colour
private
When the background colour for the model exists, return it, otherwise returns the parent background colour, or an empty Vedeu::Colours::Background.
-
#background=(value) ⇒ Vedeu::Colours::Background
included
from Presentation::Colour
private
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
-
#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.
- #cell_attributes ⇒ Hash<Symbol => void> private
- #colour ⇒ Vedeu::Colours::Colour included from Presentation::Colour private
-
#colour=(value) ⇒ Vedeu::Colours::Colour
included
from Presentation::Colour
private
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
- #colour? ⇒ Boolean included from Presentation::Colour private
-
#defaults ⇒ Hash<Symbol => Boolean|Hash|NilClass|String|Symbol| Vedeu::Borders::Repository|Vedeu::Presentation::Style>
private
The default values for a new instance of this class.
-
#deputy(client = nil) ⇒ Vedeu::Borders::DSL
Returns a DSL instance responsible for defining the DSL methods of this model.
-
#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.
-
#foreground ⇒ Vedeu::Colours::Foreground
included
from Presentation::Colour
private
When the foreground colour for the model exists, return it, otherwise returns the parent foreground colour, or an empty Vedeu::Colours::Foreground.
-
#foreground=(value) ⇒ Vedeu::Colours::Foreground
included
from Presentation::Colour
private
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
#initialize(attributes = {}) ⇒ Vedeu::Borders::Border
constructor
Returns a new instance of Vedeu::Borders::Border.
-
#line_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Line.
- #named_colour ⇒ Vedeu::Colours::Colour included from Presentation::Colour private private
- #named_colour? ⇒ Boolean included from Presentation::Colour private private
-
#numeric?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
- #parent_colour ⇒ Vedeu::Colours::Colour included from Presentation::Colour private private
- #parent_colour? ⇒ Boolean included from Presentation::Colour private private
-
#position ⇒ Vedeu::Geometries::Position
included
from Presentation::Position
private
Gets the position.
-
#position=(value) ⇒ Vedeu::Geometries::Position
included
from Presentation::Position
private
Sets the position.
-
#position? ⇒ Boolean
included
from Presentation::Position
private
Returns a boolean indicating the position attribute of the including model is set.
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#render_colour(&block) ⇒ String
included
from Presentation
private
Renders the colour attributes of the receiver and yields (to then render the styles).
- #render_position(&block) ⇒ String included from Presentation private
-
#render_style(&block) ⇒ String
included
from Presentation
private
Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).
-
#snake_case(klass) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#store(&block) ⇒ void
included
from Repositories::Model
The model instance stored in the repository.
-
#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.
-
#style ⇒ Vedeu::Presentation::Style
included
from Presentation::Styles
When the style for the model exists, return it, otherwise returns the parent style, or an empty Presentation::Style.
-
#style=(value) ⇒ Vedeu::Presentation::Style
included
from Presentation::Styles
Allows the setting of the style by coercing the given value into a Presentation::Style.
-
#to_s ⇒ String
(also: #to_str)
included
from Presentation
Converts the colours and styles to escape sequences, and when the parent model has previously set the colour and style, reverts back to that for consistent formatting.
-
#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.
-
#x ⇒ Fixnum|NilClass
included
from Presentation::Position
private
Returns the x coordinate for the model when the position attribute of the including model is set.
-
#y ⇒ Fixnum|NilClass
included
from Presentation::Position
private
Returns the y coordinate for the model when the position attribute of the including model is set.
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Borders::Border
Returns a new instance of Vedeu::Borders::Border.
167 168 169 170 171 |
# File 'lib/vedeu/borders/border.rb', line 167 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#bottom_horizontal ⇒ Vedeu::Cells::BottomHorizontal
Return the client application configured bottom horizontal cell character, or the default if not set.
267 268 269 270 |
# File 'lib/vedeu/borders/border.rb', line 267 def bottom_horizontal @bottom_horizontal ||= Vedeu::Cells::BottomHorizontal .new(cell_attributes) end |
#bottom_left ⇒ Vedeu::Cells::BottomLeft
Return the client application configured bottom left cell character, or the default if not set.
276 277 278 |
# File 'lib/vedeu/borders/border.rb', line 276 def bottom_left @bottom_left ||= Vedeu::Cells::BottomLeft.new(cell_attributes) end |
#bottom_right ⇒ Vedeu::Cells::BottomRight
Return the client application configured bottom right cell character, or the default if not set.
284 285 286 |
# File 'lib/vedeu/borders/border.rb', line 284 def bottom_right @bottom_right ||= Vedeu::Cells::BottomRight.new(cell_attributes) end |
#caption ⇒ String
Returns An optional caption for when the bottom border is to be shown.
43 44 45 |
# File 'lib/vedeu/borders/border.rb', line 43 def caption @caption end |
#enabled ⇒ Boolean Also known as: enabled?
Returns Determines whether this border should be rendered.
122 123 124 |
# File 'lib/vedeu/borders/border.rb', line 122 def enabled @enabled end |
#horizontal ⇒ String
Returns The character to be used for the horizontal side border.
48 49 50 |
# File 'lib/vedeu/borders/border.rb', line 48 def horizontal @horizontal end |
#left_vertical ⇒ Vedeu::Cells::LeftVertical
Return the client application configured left vertical cell character, or the default if not set.
227 228 229 |
# File 'lib/vedeu/borders/border.rb', line 227 def left_vertical @left_vertical ||= Vedeu::Cells::LeftVertical.new(cell_attributes) end |
#name ⇒ String|Symbol (readonly)
Returns Associates the border with the same-named interface/view.
112 113 114 |
# File 'lib/vedeu/borders/border.rb', line 112 def name @name end |
#parent ⇒ Vedeu::Interfaces::Interface|NilClass (readonly)
Returns The interface/ view associated with this border.
117 118 119 |
# File 'lib/vedeu/borders/border.rb', line 117 def parent @parent end |
#repository ⇒ Vedeu::Repositories::Repository Originally defined in module Repositories::Model
#right_vertical ⇒ Vedeu::Cells::RightVertical
Return the client application configured right vertical cell character, or the default if not set.
235 236 237 |
# File 'lib/vedeu/borders/border.rb', line 235 def right_vertical @right_vertical ||= Vedeu::Cells::RightVertical.new(cell_attributes) end |
#show_bottom ⇒ Boolean Also known as: bottom?
Returns Determines whether the bottom border should be shown.
53 54 55 |
# File 'lib/vedeu/borders/border.rb', line 53 def show_bottom @show_bottom end |
#show_left ⇒ Boolean Also known as: left?
Returns Determines whether the left border should be shown.
59 60 61 |
# File 'lib/vedeu/borders/border.rb', line 59 def show_left @show_left end |
#show_right ⇒ Boolean Also known as: right?
Returns Determines whether the right border should be shown.
65 66 67 |
# File 'lib/vedeu/borders/border.rb', line 65 def show_right @show_right end |
#show_top ⇒ Boolean Also known as: top?
Returns Determines whether the top border should be shown.
71 72 73 |
# File 'lib/vedeu/borders/border.rb', line 71 def show_top @show_top end |
#title ⇒ String
Returns An optional title for when the top border is to be shown.
77 78 79 |
# File 'lib/vedeu/borders/border.rb', line 77 def title @title end |
#top_horizontal ⇒ Vedeu::Cells::TopHorizontal
Return the client application configured top horizontal cell character, or the default if not set.
243 244 245 |
# File 'lib/vedeu/borders/border.rb', line 243 def top_horizontal @top_horizontal ||= Vedeu::Cells::TopHorizontal.new(cell_attributes) end |
#top_left ⇒ Vedeu::Cells::TopLeft
Return the client application configured top left cell character, or the default if not set.
251 252 253 |
# File 'lib/vedeu/borders/border.rb', line 251 def top_left @top_left ||= Vedeu::Cells::TopLeft.new(cell_attributes) end |
#top_right ⇒ Vedeu::Cells::TopRight
Return the client application configured top right cell character, or the default if not set.
259 260 261 |
# File 'lib/vedeu/borders/border.rb', line 259 def top_right @top_right ||= Vedeu::Cells::TopRight.new(cell_attributes) end |
#vertical ⇒ String
Returns The character to be used for the vertical side border.
97 98 99 |
# File 'lib/vedeu/borders/border.rb', line 97 def vertical @vertical 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 => Boolean|Hash|NilClass|String|Symbol| Vedeu::Borders::Repository|Vedeu::Presentation::Style>
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/vedeu/borders/border.rb', line 175 def attributes { bottom_horizontal: bottom_horizontal, bottom_left: bottom_left, bottom_right: bottom_right, caption: caption, client: @client, colour: colour, enabled: @enabled, horizontal: @horizontal, left_vertical: left_vertical, name: name, parent: @parent, repository: @repository, right_vertical: right_vertical, show_bottom: @show_bottom, show_left: @show_left, show_right: @show_right, show_top: @show_top, style: style, title: title, top_horizontal: top_horizontal, top_left: top_left, top_right: top_right, vertical: @vertical, } end |
#background ⇒ Vedeu::Colours::Background Originally defined in module Presentation::Colour
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.
When the background colour for the model exists, return it, otherwise returns the parent background colour, or an empty Vedeu::Colours::Background.
#background=(value) ⇒ Vedeu::Colours::Background Originally defined in module Presentation::Colour
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.
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
#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.
#cell_attributes ⇒ Hash<Symbol => void> (private)
299 300 301 302 303 304 305 |
# File 'lib/vedeu/borders/border.rb', line 299 def cell_attributes { colour: colour, name: name, style: style, } end |
#colour ⇒ Vedeu::Colours::Colour Originally defined in module Presentation::Colour
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.
#colour=(value) ⇒ Vedeu::Colours::Colour Originally defined in module Presentation::Colour
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.
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
#colour? ⇒ Boolean Originally defined in module Presentation::Colour
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.
#defaults ⇒ Hash<Symbol => Boolean|Hash|NilClass|String|Symbol| Vedeu::Borders::Repository|Vedeu::Presentation::Style> (private)
The default values for a new instance of this class.
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/vedeu/borders/border.rb', line 312 def defaults { bottom_horizontal: nil, bottom_left: nil, bottom_right: nil, caption: '', client: nil, colour: nil, enabled: false, horizontal: Vedeu.esc.horizontal, left_vertical: nil, name: '', parent: nil, repository: Vedeu.borders, right_vertical: nil, show_bottom: true, show_left: true, show_right: true, show_top: true, style: nil, title: '', top_horizontal: nil, top_left: nil, top_right: nil, vertical: Vedeu.esc.vertical, } end |
#deputy(client = nil) ⇒ Vedeu::Borders::DSL
Returns a DSL instance responsible for defining the DSL methods of this model.
219 220 221 |
# File 'lib/vedeu/borders/border.rb', line 219 def deputy(client = nil) Vedeu::Borders::DSL.new(self, client) 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.
#foreground ⇒ Vedeu::Colours::Foreground Originally defined in module Presentation::Colour
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.
When the foreground colour for the model exists, return it, otherwise returns the parent foreground colour, or an empty Vedeu::Colours::Foreground.
#foreground=(value) ⇒ Vedeu::Colours::Foreground Originally defined in module Presentation::Colour
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.
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
#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.
#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.
#named_colour ⇒ Vedeu::Colours::Colour (private) Originally defined in module Presentation::Colour
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.
#named_colour? ⇒ Boolean (private) Originally defined in module Presentation::Colour
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.
#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.
#parent_colour ⇒ Vedeu::Colours::Colour (private) Originally defined in module Presentation::Colour
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.
#parent_colour? ⇒ Boolean (private) Originally defined in module Presentation::Colour
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.
#position ⇒ Vedeu::Geometries::Position Originally defined in module Presentation::Position
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.
Gets the position.
#position=(value) ⇒ Vedeu::Geometries::Position Originally defined in module Presentation::Position
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.
Sets the position.
#position? ⇒ Boolean Originally defined in module Presentation::Position
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 position attribute of the including model is set.
#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_colour(&block) ⇒ String (private) Originally defined in module Presentation
Renders the colour attributes of the receiver and yields (to then render the styles).
#render_position(&block) ⇒ String (private) Originally defined in module Presentation
#render_style(&block) ⇒ String (private) Originally defined in module Presentation
Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).
#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.
#store(&block) ⇒ void Originally defined in module Repositories::Model
Perhaps some validation could be added here?
If a block is given, store the model, return the model after yielding.
This method returns an undefined value.
Returns The model instance stored in the repository.
#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.
#style ⇒ Vedeu::Presentation::Style Originally defined in module Presentation::Styles
When the style for the model exists, return it, otherwise returns the parent style, or an empty Vedeu::Presentation::Style.
#style=(value) ⇒ Vedeu::Presentation::Style Originally defined in module Presentation::Styles
Allows the setting of the style by coercing the given value into a Vedeu::Presentation::Style.
#to_s ⇒ String Also known as: to_str Originally defined in module Presentation
Converts the colours and styles to escape sequences, and when the parent model has previously set the colour and style, reverts back to that for consistent formatting.
#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.
#x ⇒ Fixnum|NilClass Originally defined in module Presentation::Position
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 x coordinate for the model when the position attribute of the including model is set.
#y ⇒ Fixnum|NilClass Originally defined in module Presentation::Position
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 y coordinate for the model when the position attribute of the including model is set.