Class: Vedeu::Borders::Border

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
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

Attributes included from Repositories::Model

#repository

Instance Method Summary collapse

Methods included from Presentation

#to_s

Methods included from Presentation::Styles

#render_style, #style, #style=

Methods included from Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Methods included from Presentation::Position

#position, #position=, #position?, #render_position, #x, #y

Methods included from Presentation::Colour

#background, #background=, #colour, #colour=, #colour?, #foreground, #foreground=, #named_colour, #named_colour?, #parent_colour, #parent_colour?, #render_colour

Methods included from Repositories::Model

included, #store

Constructor Details

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

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

Parameters:

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.

  • left_vertical (String)

    The left vertical border character.

  • name (String|Symbol)

    The name of the interface to which this border relates.

  • right_vertical (String)

    The right vertical border character.

  • 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_horizontal (String)

    The top horizontal border character.

  • top_left (String)

    The top left border character.

  • top_right (String)

    The top right border character.

  • vertical (String)

    The vertical border character.



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_horizontalVedeu::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_leftVedeu::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_rightVedeu::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

#captionString

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

Returns:

  • (String)

    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

#enabledBoolean Also known as: enabled?

Returns Determines whether this border should be rendered.

Returns:

  • (Boolean)

    Determines whether this border should be rendered.



122
123
124
# File 'lib/vedeu/borders/border.rb', line 122

def enabled
  @enabled
end

#horizontalString

Returns The character to be used for the horizontal side border.

Returns:

  • (String)

    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_verticalVedeu::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

#nameString|Symbol (readonly)

Returns Associates the border with the same-named interface/view.

Returns:

  • (String|Symbol)

    Associates the border with the same-named interface/view.



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

def name
  @name
end

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

Returns The interface/ view associated with this border.

Returns:



117
118
119
# File 'lib/vedeu/borders/border.rb', line 117

def parent
  @parent
end

#right_verticalVedeu::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_bottomBoolean Also known as: bottom?

Returns Determines whether the bottom border should be shown.

Returns:

  • (Boolean)

    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_leftBoolean Also known as: left?

Returns Determines whether the left border should be shown.

Returns:

  • (Boolean)

    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_rightBoolean Also known as: right?

Returns Determines whether the right border should be shown.

Returns:

  • (Boolean)

    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_topBoolean Also known as: top?

Returns Determines whether the top border should be shown.

Returns:

  • (Boolean)

    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

#titleString

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

Returns:

  • (String)

    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_horizontalVedeu::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_leftVedeu::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_rightVedeu::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

#verticalString

Returns The character to be used for the vertical side border.

Returns:

  • (String)

    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

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

Returns:



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

#cell_attributesHash<Symbol => void> (private)

Returns:

  • (Hash<Symbol => void>)


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

#defaultsHash<Symbol => void> (private)

The default options/attributes for a new instance of this class.

Returns:

  • (Hash<Symbol => void>)


308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/vedeu/borders/border.rb', line 308

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.

Parameters:

  • client (Object|NilClass) (defaults to: nil)

    The client binding represents the client application object that is currently invoking a DSL method. It is required so that we can send messages to the client application object should we need to.

Returns:



219
220
221
# File 'lib/vedeu/borders/border.rb', line 219

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