Class: Vedeu::Borders::Border
- Inherits:
-
Object
- Object
- Vedeu::Borders::Border
- Extended by:
- Forwardable
- Includes:
- Common, 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_left ⇒ String
The character to be used for the bottom left border if enabled.
-
#bottom_right ⇒ String
The character to be used for the bottom right border if enabled.
-
#enabled ⇒ Boolean
(also: #enabled?)
Determines whether this border should be rendered.
-
#horizontal ⇒ String
The character to be used for the horizontal side border.
-
#name ⇒ String
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
-
#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 ⇒ Vedeu::Borders::Title
-
#top_left ⇒ String
The character to be used for the top left border if enabled.
-
#top_right ⇒ String
The character to be used for the top right border if enabled.
-
#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
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
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
-
#bx ⇒ Fixnum
Return the column position for 1 character right of the left border.
-
#bxn ⇒ Fixnum
Return the column position for 1 character left of the right border.
-
#by ⇒ Fixnum
Return the row position for 1 character under of the top border.
-
#byn ⇒ Fixnum
Return the column position for 1 character above of the bottom border.
- #caption ⇒ Vedeu::Borders::Caption
- #caption=(value) ⇒ Vedeu::Borders::Caption
- #colour ⇒ Vedeu::Colours::Colour included from Presentation::Colour
-
#colour=(value) ⇒ Vedeu::Colours::Colour
included
from Presentation::Colour
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
-
#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.
-
#demodulize(klass) ⇒ String
included
from Common
private
Removes the module part from the expression in the string.
-
#deputy(client = nil) ⇒ Vedeu::Borders::DSL
Returns a DSL instance responsible for defining the DSL methods of this model.
-
#foreground ⇒ Vedeu::Colours::Foreground
included
from Presentation::Colour
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
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
-
#geometry ⇒ Object
private
Returns the geometry for the interface.
-
#height ⇒ Fixnum
Returns the height of the interface determined by whether a top, bottom, both or neither borders are shown.
-
#initialize(attributes = {}) ⇒ Vedeu::Borders::Border
constructor
Returns a new instance of Vedeu::Borders::Border.
-
#position? ⇒ Boolean
included
from Presentation
private
Returns a boolean indicating the model has a position attribute.
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#render_colour ⇒ String
included
from Presentation
private
Renders the colour attributes of the receiver and yields (to then render the styles).
- #render_position ⇒ String included from Presentation private
-
#render_style ⇒ 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(name) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#store ⇒ void
included
from Repositories::Model
The model instance stored in the repository.
-
#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.
-
#width ⇒ Fixnum
Returns the width of the interface determined by whether a left, right, both or neither borders are shown.
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Borders::Border
Returns a new instance of Vedeu::Borders::Border.
146 147 148 149 150 |
# File 'lib/vedeu/borders/border.rb', line 146 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#bottom_left ⇒ String
Returns The character to be used for the bottom left border if enabled.
33 34 35 |
# File 'lib/vedeu/borders/border.rb', line 33 def bottom_left @bottom_left end |
#bottom_right ⇒ String
Returns The character to be used for the bottom right border if enabled.
38 39 40 |
# File 'lib/vedeu/borders/border.rb', line 38 def bottom_right @bottom_right end |
#enabled ⇒ Boolean Also known as: enabled?
Returns Determines whether this border should be rendered.
107 108 109 |
# File 'lib/vedeu/borders/border.rb', line 107 def enabled @enabled end |
#horizontal ⇒ String
Returns The character to be used for the horizontal side border.
43 44 45 |
# File 'lib/vedeu/borders/border.rb', line 43 def horizontal @horizontal end |
#name ⇒ String (readonly)
Returns Associates the border with the same-named interface/view.
97 98 99 |
# File 'lib/vedeu/borders/border.rb', line 97 def name @name end |
#parent ⇒ Vedeu::Interfaces::Interface|NilClass (readonly)
Returns The interface/ view associated with this border.
102 103 104 |
# File 'lib/vedeu/borders/border.rb', line 102 def parent @parent end |
#repository ⇒ Vedeu::Repositories::Repository Originally defined in module Repositories::Model
#show_bottom ⇒ Boolean Also known as: bottom?
Returns Determines whether the bottom border should be shown.
48 49 50 |
# File 'lib/vedeu/borders/border.rb', line 48 def show_bottom @show_bottom end |
#show_left ⇒ Boolean Also known as: left?
Returns Determines whether the left border should be shown.
54 55 56 |
# File 'lib/vedeu/borders/border.rb', line 54 def show_left @show_left end |
#show_right ⇒ Boolean Also known as: right?
Returns Determines whether the right border should be shown.
60 61 62 |
# File 'lib/vedeu/borders/border.rb', line 60 def show_right @show_right end |
#show_top ⇒ Boolean Also known as: top?
Returns Determines whether the top border should be shown.
66 67 68 |
# File 'lib/vedeu/borders/border.rb', line 66 def show_top @show_top end |
#top_left ⇒ String
Returns The character to be used for the top left border if enabled.
82 83 84 |
# File 'lib/vedeu/borders/border.rb', line 82 def top_left @top_left end |
#top_right ⇒ String
Returns The character to be used for the top right border if enabled.
87 88 89 |
# File 'lib/vedeu/borders/border.rb', line 87 def top_right @top_right end |
#vertical ⇒ String
Returns The character to be used for the vertical side border.
92 93 94 |
# File 'lib/vedeu/borders/border.rb', line 92 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>
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/vedeu/borders/border.rb', line 154 def attributes { bottom_left: @bottom_left, bottom_right: @bottom_right, caption: @caption, client: @client, colour: @colour, enabled: @enabled, horizontal: @horizontal, name: @name, parent: @parent, repository: @repository, show_bottom: @show_bottom, show_left: @show_left, show_right: @show_right, show_top: @show_top, style: @style, title: @title, top_left: @top_left, top_right: @top_right, vertical: @vertical, } end |
#background ⇒ Vedeu::Colours::Background Originally defined in module Presentation::Colour
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
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
#bx ⇒ Fixnum
Return the column position for 1 character right of the left
border.
182 183 184 |
# File 'lib/vedeu/borders/border.rb', line 182 def bx (enabled? && left?) ? x + 1 : x end |
#bxn ⇒ Fixnum
Return the column position for 1 character left of the right
border.
190 191 192 |
# File 'lib/vedeu/borders/border.rb', line 190 def bxn (enabled? && right?) ? xn - 1 : xn end |
#by ⇒ Fixnum
Return the row position for 1 character under of the top
border.
198 199 200 |
# File 'lib/vedeu/borders/border.rb', line 198 def by (enabled? && top?) ? y + 1 : y end |
#byn ⇒ Fixnum
Return the column position for 1 character above of the bottom
border.
206 207 208 |
# File 'lib/vedeu/borders/border.rb', line 206 def byn (enabled? && bottom?) ? yn - 1 : yn end |
#caption ⇒ Vedeu::Borders::Caption
211 212 213 |
# File 'lib/vedeu/borders/border.rb', line 211 def caption Vedeu::Borders::Caption.coerce(@caption, width) end |
#caption=(value) ⇒ Vedeu::Borders::Caption
217 218 219 |
# File 'lib/vedeu/borders/border.rb', line 217 def caption=(value) @caption = Vedeu::Borders::Caption.coerce(value, width) end |
#colour ⇒ Vedeu::Colours::Colour Originally defined in module Presentation::Colour
#colour=(value) ⇒ Vedeu::Colours::Colour Originally defined in module Presentation::Colour
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
#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.
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/vedeu/borders/border.rb', line 274 def defaults { bottom_left: Vedeu::EscapeSequences::Borders.bottom_left, bottom_right: Vedeu::EscapeSequences::Borders.bottom_right, caption: '', client: nil, colour: nil, enabled: false, horizontal: Vedeu::EscapeSequences::Borders.horizontal, name: '', parent: nil, repository: Vedeu.borders, show_bottom: true, show_left: true, show_right: true, show_top: true, style: nil, title: '', top_left: Vedeu::EscapeSequences::Borders.top_left, top_right: Vedeu::EscapeSequences::Borders.top_right, vertical: Vedeu::EscapeSequences::Borders.vertical, } 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.
#deputy(client = nil) ⇒ Vedeu::Borders::DSL
Returns a DSL instance responsible for defining the DSL methods of this model.
240 241 242 |
# File 'lib/vedeu/borders/border.rb', line 240 def deputy(client = nil) Vedeu::Borders::DSL.new(self, client) end |
#foreground ⇒ Vedeu::Colours::Foreground Originally defined in module Presentation::Colour
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
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
#geometry ⇒ Object (private)
Returns the geometry for the interface.
265 266 267 |
# File 'lib/vedeu/borders/border.rb', line 265 def geometry Vedeu.geometries.by_name(name) end |
#height ⇒ Fixnum
Returns the height of the interface determined by whether a top, bottom, both or neither borders are shown.
256 257 258 |
# File 'lib/vedeu/borders/border.rb', line 256 def height (by..byn).size end |
#position? ⇒ Boolean (private) Originally defined in module Presentation
Returns a boolean indicating the model has a position attribute.
#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 ⇒ String (private) Originally defined in module Presentation
Renders the colour attributes of the receiver and yields (to then render the styles).
#render_position ⇒ String (private) Originally defined in module Presentation
#render_style ⇒ 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(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.
#store ⇒ 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.
#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.
#width ⇒ Fixnum
Returns the width of the interface determined by whether a left, right, both or neither borders are shown.
248 249 250 |
# File 'lib/vedeu/borders/border.rb', line 248 def width (bx..bxn).size end |