Class: Vedeu::Borders::Refresh Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Common
Defined in:
lib/vedeu/borders/refresh.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Renders and refreshes the named border.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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?

Constructor Details

#initialize(name = Vedeu.focus) ⇒ Vedeu::Borders::Refresh

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 new instance of Vedeu::Borders::Refresh.

Parameters:

  • name (NilClass|Symbol|String) (defaults to: Vedeu.focus)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.



67
68
69
# File 'lib/vedeu/borders/refresh.rb', line 67

def initialize(name = Vedeu.focus)
  @name = present?(name) ? name : Vedeu.focus
end

Instance Attribute Details

#nameString|Symbol (readonly, protected)

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:

  • (String|Symbol)


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

def name
  @name
end

Class Method Details

.by_name(name = Vedeu.focus) ⇒ Array<Array<Vedeu::Cells::Char>>

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.

Parameters:

  • name (NilClass|Symbol|String) (defaults to: Vedeu.focus)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.

Returns:



57
58
59
60
61
# File 'lib/vedeu/borders/refresh.rb', line 57

def self.by_name(name = Vedeu.focus)
  name || Vedeu.focus

  new(name).by_name
end

Instance Method Details

#attributesHash<Symbol => void> (private)

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:

  • (Hash<Symbol => void>)


86
87
88
89
90
91
92
# File 'lib/vedeu/borders/refresh.rb', line 86

def attributes
  {
    colour: colour,
    name:   name,
    style:  style,
  }
end

#borderObject (private)

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 border for the interface.



97
98
99
# File 'lib/vedeu/borders/refresh.rb', line 97

def border
  @border ||= Vedeu.borders.by_name(name)
end

#bottomString (private)

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.

Note:

If a caption has been specified, then the bottom border will include this caption unless the size of the interface is smaller than the padded caption length.

Renders the bottom border for the interface.

Returns:

  • (String)


121
122
123
# File 'lib/vedeu/borders/refresh.rb', line 121

def bottom
  [(bottom_left if left?), captionbar, (bottom_right if right?)].compact
end

#build_collection(size, &block) ⇒ Array<void> (private)

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.

Build a collection with the given size of objects given within the block.

Parameters:

  • size (Fixnum)
  • block (Proc)

Returns:

  • (Array<void>)


213
214
215
# File 'lib/vedeu/borders/refresh.rb', line 213

def build_collection(size, &block)
  Array.new(size) { |e| yield(e) }
end

#by_nameArray<Array<Vedeu::Cells::Char>> Also known as: render

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:



72
73
74
# File 'lib/vedeu/borders/refresh.rb', line 72

def by_name
  Vedeu.render_output(output) if enabled? && visible?
end

#captionbarObject (private)

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.

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



180
181
182
183
184
185
186
187
188
189
190
# File 'lib/vedeu/borders/refresh.rb', line 180

def captionbar
  characters = build_collection(bordered_width) do |ix|
    cell = bottom_horizontal.dup
    cell.position = [yn, bx + ix]
    cell
  end

  return characters unless present?(caption)

  Vedeu::Borders::Caption.render(name, caption, characters)
end

#geometryObject (private)

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 geometry for the interface.



128
129
130
# File 'lib/vedeu/borders/refresh.rb', line 128

def geometry
  Vedeu.geometries.by_name(name)
end

#interfaceObject (private) Also known as: parent

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.

Note:

The parent of a border is always an interface.

Returns the interface by name.



138
139
140
# File 'lib/vedeu/borders/refresh.rb', line 138

def interface
  @interface ||= Vedeu.interfaces.by_name(name)
end

#leftArray<void> (private)

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.

Renders the left border for the interface.

Returns:

  • (Array<void>)


146
147
148
149
150
151
152
# File 'lib/vedeu/borders/refresh.rb', line 146

def left
  build_collection(bordered_height) do |iy|
    cell = left_vertical.dup
    cell.position = [by + iy, x]
    cell
  end
end

#outputArray<Array<Vedeu::Cells::Char>> (private)

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:



102
103
104
105
106
107
108
109
110
111
# File 'lib/vedeu/borders/refresh.rb', line 102

def output
  Vedeu.timer("Drawing border: '#{name}'") do
    [
      (top if top?),
      (left if left?),
      (right if right?),
      (bottom if bottom?),
    ].flatten
  end
end

#rightArray<void> (private)

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.

Renders the right border for the interface.

Returns:

  • (Array<void>)


157
158
159
160
161
162
163
# File 'lib/vedeu/borders/refresh.rb', line 157

def right
  build_collection(bordered_height) do |iy|
    cell = right_vertical.dup
    cell.position = [by + iy, xn]
    cell
  end
end

#titlebarArray<Vedeu::Cells::Horizontal|Vedeu::Cells::Char> (private)

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.

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



195
196
197
198
199
200
201
202
203
204
205
# File 'lib/vedeu/borders/refresh.rb', line 195

def titlebar
  characters = build_collection(bordered_width) do |ix|
    cell = top_horizontal.dup
    cell.position = [y, bx + ix]
    cell
  end

  return characters unless present?(title)

  Vedeu::Borders::Title.render(name, title, characters)
end

#topString (private)

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.

Note:

If a title has been specified, then the top border will include this title unless the size of the interface is smaller than the padded title length.

Renders the top border for the interface.

Returns:

  • (String)


173
174
175
# File 'lib/vedeu/borders/refresh.rb', line 173

def top
  [(top_left if left?), titlebar, (top_right if right?)].compact
end