Class: Vedeu::Borders::Border

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Common, Presentation, Repositories::Model
Defined in:
lib/vedeu/borders/border.rb

Overview

Note:

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Vedeu::Borders::Border

Returns a new instance of Vedeu::Borders::Border.

Options Hash (attributes):

  • bottom_left (String)

    The bottom left border character.

  • bottom_right (String)

    The bottom right border character.

  • colour (Hash)
  • enabled (Boolean)

    Indicate whether the border is to be shown for this interface.

  • horizontal (String)

    The horizontal border character.

  • name (String|Symbol)

    The name of the interface to which this border relates.

  • style (Vedeu::Presentation::Style)
  • show_bottom (Boolean)

    Indicate whether the bottom border is to be shown.

  • show_left (Boolean)

    Indicate whether the left border is to be shown.

  • show_right (Boolean)

    Indicate whether the right border is to be shown.

  • show_top (Boolean)

    Indicate whether the top border is to be shown.

  • title (String)

    An optional title for when the top border is to be shown.

  • caption (String)

    An optional caption for when the bottom border is to be shown.

  • top_left (String)

    The top left border character.

  • top_right (String)

    The top right border character.

  • vertical (String)

    The vertical border character.



150
151
152
153
154
# File 'lib/vedeu/borders/border.rb', line 150

def initialize(attributes = {})
  defaults.merge!(attributes).each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#bottom_leftString



37
38
39
# File 'lib/vedeu/borders/border.rb', line 37

def bottom_left
  @bottom_left
end

#bottom_rightString



42
43
44
# File 'lib/vedeu/borders/border.rb', line 42

def bottom_right
  @bottom_right
end

#captionString



47
48
49
# File 'lib/vedeu/borders/border.rb', line 47

def caption
  @caption
end

#enabledBoolean Also known as: enabled?



111
112
113
# File 'lib/vedeu/borders/border.rb', line 111

def enabled
  @enabled
end

#horizontalString



52
53
54
# File 'lib/vedeu/borders/border.rb', line 52

def horizontal
  @horizontal
end

#nameString|Symbol (readonly)



101
102
103
# File 'lib/vedeu/borders/border.rb', line 101

def name
  @name
end

#parentVedeu::Interfaces::Interface|NilClass (readonly)



106
107
108
# File 'lib/vedeu/borders/border.rb', line 106

def parent
  @parent
end

#repositoryVedeu::Repositories::Repository Originally defined in module Repositories::Model

#show_bottomBoolean Also known as: bottom?



57
58
59
# File 'lib/vedeu/borders/border.rb', line 57

def show_bottom
  @show_bottom
end

#show_leftBoolean Also known as: left?



63
64
65
# File 'lib/vedeu/borders/border.rb', line 63

def show_left
  @show_left
end

#show_rightBoolean Also known as: right?



69
70
71
# File 'lib/vedeu/borders/border.rb', line 69

def show_right
  @show_right
end

#show_topBoolean Also known as: top?



75
76
77
# File 'lib/vedeu/borders/border.rb', line 75

def show_top
  @show_top
end

#titleString



81
82
83
# File 'lib/vedeu/borders/border.rb', line 81

def title
  @title
end

#top_leftString



86
87
88
# File 'lib/vedeu/borders/border.rb', line 86

def top_left
  @top_left
end

#top_rightString



91
92
93
# File 'lib/vedeu/borders/border.rb', line 91

def top_right
  @top_right
end

#verticalString



96
97
98
# File 'lib/vedeu/borders/border.rb', line 96

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.

#attributesHash<Symbol => Boolean|Hash|NilClass|String|Symbol| Vedeu::Borders::Repository|Vedeu::Presentation::Style>



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/vedeu/borders/border.rb', line 158

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

#backgroundVedeu::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.

#colourVedeu::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.

#defaultsHash<Symbol => Boolean|Hash|NilClass|String|Symbol| Vedeu::Borders::Repository|Vedeu::Presentation::Style> (private)

The default values for a new instance of this class.



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/vedeu/borders/border.rb', line 208

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.

Examples:

demodulize('Vedeu::SomeModule::SomeClass') # => "SomeClass"

#deputy(client = nil) ⇒ Vedeu::Borders::DSL

Returns a DSL instance responsible for defining the DSL methods of this model.



190
191
192
# File 'lib/vedeu/borders/border.rb', line 190

def deputy(client = nil)
  Vedeu::Borders::DSL.new(self, client)
end

#foregroundVedeu::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.

#geometryObject (private)

Returns the geometry for the interface.



199
200
201
# File 'lib/vedeu/borders/border.rb', line 199

def geometry
  Vedeu.geometries.by_name(name)
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_colourString (private) Originally defined in module Presentation

Renders the colour attributes of the receiver and yields (to then render the styles).

#render_positionString (private) Originally defined in module Presentation

#render_styleString (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.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

#storevoid Originally defined in module Repositories::Model

TODO:

Perhaps some validation could be added here?

Note:

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.

#styleVedeu::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_sString 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.