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
- #bottom_right ⇒ String
-
#caption ⇒ String
An optional caption for when the bottom border is to be shown.
- #enabled ⇒ Boolean (also: #enabled?)
- #horizontal ⇒ String
- #name ⇒ String readonly
- #parent ⇒ Vedeu::Interfaces::Interface|NilClass readonly
- #repository ⇒ Vedeu::Repositories::Repository included from Repositories::Model
- #show_bottom ⇒ Boolean (also: #bottom?)
- #show_left ⇒ Boolean (also: #left?)
- #show_right ⇒ Boolean (also: #right?)
- #show_top ⇒ Boolean (also: #top?)
-
#title ⇒ String
An optional title for when the top border is to be shown.
- #top_left ⇒ String
- #top_right ⇒ String
- #vertical ⇒ String
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
Returns a boolean indicating whether a variable is nil or empty.
- #attributes ⇒ Hash
-
#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
- #bxn ⇒ Fixnum
- #by ⇒ Fixnum
- #byn ⇒ Fixnum
- #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
private
The default values for a new instance of this class.
-
#demodulize(klass) ⇒ String
included
from Common
Removes the module part from the expression in the string.
-
#deputy(client = nil) ⇒ void
included
from Repositories::Model
Returns a DSL instance responsible for defining the DSL methods of this model.
-
#dsl_class ⇒ String
included
from Repositories::Model
private
Returns the DSL class name responsible for 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 ⇒ Vedeu::Geometry::Geometry private
-
#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
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
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.
131 132 133 134 135 |
# File 'lib/vedeu/borders/border.rb', line 131 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#bottom_left ⇒ String
32 33 34 |
# File 'lib/vedeu/borders/border.rb', line 32 def bottom_left @bottom_left end |
#bottom_right ⇒ String
36 37 38 |
# File 'lib/vedeu/borders/border.rb', line 36 def bottom_right @bottom_right end |
#caption ⇒ String
65 66 67 |
# File 'lib/vedeu/borders/border.rb', line 65 def caption @caption end |
#enabled ⇒ Boolean Also known as: enabled?
94 95 96 |
# File 'lib/vedeu/borders/border.rb', line 94 def enabled @enabled end |
#horizontal ⇒ String
40 41 42 |
# File 'lib/vedeu/borders/border.rb', line 40 def horizontal @horizontal end |
#name ⇒ String (readonly)
86 87 88 |
# File 'lib/vedeu/borders/border.rb', line 86 def name @name end |
#parent ⇒ Vedeu::Interfaces::Interface|NilClass (readonly)
90 91 92 |
# File 'lib/vedeu/borders/border.rb', line 90 def parent @parent end |
#repository ⇒ Vedeu::Repositories::Repository Originally defined in module Repositories::Model
#show_bottom ⇒ Boolean Also known as: bottom?
44 45 46 |
# File 'lib/vedeu/borders/border.rb', line 44 def show_bottom @show_bottom end |
#show_left ⇒ Boolean Also known as: left?
49 50 51 |
# File 'lib/vedeu/borders/border.rb', line 49 def show_left @show_left end |
#show_right ⇒ Boolean Also known as: right?
54 55 56 |
# File 'lib/vedeu/borders/border.rb', line 54 def show_right @show_right end |
#show_top ⇒ Boolean Also known as: top?
59 60 61 |
# File 'lib/vedeu/borders/border.rb', line 59 def show_top @show_top end |
#title ⇒ String
70 71 72 |
# File 'lib/vedeu/borders/border.rb', line 70 def title @title end |
#top_left ⇒ String
74 75 76 |
# File 'lib/vedeu/borders/border.rb', line 74 def top_left @top_left end |
#top_right ⇒ String
78 79 80 |
# File 'lib/vedeu/borders/border.rb', line 78 def top_right @top_right end |
#vertical ⇒ String
82 83 84 |
# File 'lib/vedeu/borders/border.rb', line 82 def vertical @vertical end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Common
Returns a boolean indicating whether a variable is nil or empty.
#attributes ⇒ Hash
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/vedeu/borders/border.rb', line 138 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
163 164 165 |
# File 'lib/vedeu/borders/border.rb', line 163 def bx (enabled? && left?) ? x + 1 : x end |
#bxn ⇒ Fixnum
168 169 170 |
# File 'lib/vedeu/borders/border.rb', line 168 def bxn (enabled? && right?) ? xn - 1 : xn end |
#by ⇒ Fixnum
173 174 175 |
# File 'lib/vedeu/borders/border.rb', line 173 def by (enabled? && top?) ? y + 1 : y end |
#byn ⇒ Fixnum
178 179 180 |
# File 'lib/vedeu/borders/border.rb', line 178 def byn (enabled? && bottom?) ? yn - 1 : yn 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 (private)
The default values for a new instance of this class.
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/vedeu/borders/border.rb', line 209 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
Removes the module part from the expression in the string.
#deputy(client = nil) ⇒ void Originally defined in module Repositories::Model
This method returns an undefined value.
Returns a DSL instance responsible for defining the DSL methods of this model.
#dsl_class ⇒ String (private) Originally defined in module Repositories::Model
Returns the DSL class name responsible for this model.
#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 ⇒ Vedeu::Geometry::Geometry (private)
201 202 203 |
# File 'lib/vedeu/borders/border.rb', line 201 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.
194 195 196 |
# File 'lib/vedeu/borders/border.rb', line 194 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
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
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.
186 187 188 |
# File 'lib/vedeu/borders/border.rb', line 186 def width (bx..bxn).size end |