Class: Vedeu::Interfaces::ClearContent Private

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vedeu/interfaces/clear_content.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.

Clear the content of the named interface.

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::Interfaces::ClearContent

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.

Return a new instance of Vedeu::Interfaces::ClearContent.

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`.



30
31
32
# File 'lib/vedeu/interfaces/clear_content.rb', line 30

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

Instance Attribute Details

#nameNilClass|Symbol|String (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 The name of the model, the target model or the name of the associated model.

Returns:

  • (NilClass|Symbol|String)

    The name of the model, the target model or the name of the associated model.



45
46
47
# File 'lib/vedeu/interfaces/clear_content.rb', line 45

def name
  @name
end

Class Method Details

.clear_content_by_name(name = Vedeu.focus) ⇒ Vedeu::Buffers::View

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:

See Also:



20
21
22
# File 'lib/vedeu/interfaces/clear_content.rb', line 20

def clear_content_by_name(name = Vedeu.focus)
  new(name).render
end

Instance Method Details

#charsString (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 A string of blank characters.

Returns:

  • (String)

    A string of blank characters.



50
51
52
# File 'lib/vedeu/interfaces/clear_content.rb', line 50

def chars
  @_chars ||= (' ' * width)
end

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



55
56
57
# File 'lib/vedeu/interfaces/clear_content.rb', line 55

def colour
  @_colour ||= interface.colour
end

#geometryVedeu::Geometries::Geometry (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 named geometry from the geometries repository.



60
61
62
# File 'lib/vedeu/interfaces/clear_content.rb', line 60

def geometry
  @_geometry ||= Vedeu.geometries.by_name(name)
end

#heightFixnum (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:

  • (Fixnum)


65
66
67
# File 'lib/vedeu/interfaces/clear_content.rb', line 65

def height
  @_height ||= geometry.bordered_height
end

#interfaceVedeu::Interfaces::Interface (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 named interface/view from the interfaces repository.



70
71
72
# File 'lib/vedeu/interfaces/clear_content.rb', line 70

def interface
  Vedeu.interfaces.by_name(name)
end

#optimised_outputString (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:

  • (String)


75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vedeu/interfaces/clear_content.rb', line 75

def optimised_output
  Vedeu.timer("Optimised clearing content: '#{name}'") do
    Array.new(height) do |iy|
      [
        Vedeu::Geometries::Position.new(y + iy, x).to_s,
        colour.to_s,
        chars,
      ].join
    end.join + Vedeu::Geometries::Position.new(y, x).to_s
  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.

For each visible line of the interface, set the foreground and background colours to those specified when the interface was defined, then starting write space characters over the area which the interface occupies.

Returns:



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/vedeu/interfaces/clear_content.rb', line 93

def output
  Vedeu.timer("Clearing content: '#{name}'") do
    @_clear ||= Array.new(height) do |iy|
      Array.new(width) do |ix|
        position = Vedeu::Geometries::Position.new((y + iy), (x + ix))
        Vedeu::Cells::Clear.new(colour:   colour,
                                name:     name,
                                position: position)
      end
    end
  end
end

#renderVedeu::Buffers::View

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.



35
36
37
38
39
# File 'lib/vedeu/interfaces/clear_content.rb', line 35

def render
  Vedeu.direct_write(optimised_output)

  Vedeu.buffer_update(output)
end

#widthFixnum (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:

  • (Fixnum)


107
108
109
# File 'lib/vedeu/interfaces/clear_content.rb', line 107

def width
  @_width ||= geometry.bordered_width
end

#xFixnum (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:

  • (Fixnum)


117
118
119
# File 'lib/vedeu/interfaces/clear_content.rb', line 117

def x
  @_x ||= geometry.bx
end

#yFixnum (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:

  • (Fixnum)


112
113
114
# File 'lib/vedeu/interfaces/clear_content.rb', line 112

def y
  @_y ||= geometry.by
end