Class: Vedeu::Clear::NamedInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/output/clear/named_interface.rb

Overview

Clear the named interface.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Vedeu::Clear::NamedInterface

Return a new instance of Vedeu::Clear::NamedInterface.



32
33
34
# File 'lib/vedeu/output/clear/named_interface.rb', line 32

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameString (readonly, protected)



45
46
47
# File 'lib/vedeu/output/clear/named_interface.rb', line 45

def name
  @name
end

Class Method Details

.by_nameArray<Array<Vedeu::Views::Char>>

Clear the interface with the given name.

Examples:

Vedeu.clear_by_name(name)

See Also:



24
25
26
# File 'lib/vedeu/output/clear/named_interface.rb', line 24

def render(name)
  new(name).render
end

.clear_by_nameArray<Array<Vedeu::Views::Char>>

Clear the interface with the given name.

Examples:

Vedeu.clear_by_name(name)

See Also:



23
24
25
# File 'lib/vedeu/output/clear/named_interface.rb', line 23

def render(name)
  new(name).render
end

.render(name) ⇒ Array<Array<Vedeu::Views::Char>>

Clear the interface with the given name.

Examples:

Vedeu.clear_by_name(name)

See Also:



20
21
22
# File 'lib/vedeu/output/clear/named_interface.rb', line 20

def render(name)
  new(name).render
end

Instance Method Details

#geometryObject (private)

See Also:

  • Geometry::Repository#by_name


50
51
52
# File 'lib/vedeu/output/clear/named_interface.rb', line 50

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

#interfaceObject (private)

See Also:

  • Models::Interfaces#by_name


55
56
57
# File 'lib/vedeu/output/clear/named_interface.rb', line 55

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

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

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.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/vedeu/output/clear/named_interface.rb', line 65

def output
  Vedeu.timer("Clearing: '#{name}'") do
    @y      = geometry.y
    @x      = geometry.x
    @width  = geometry.width
    @height = geometry.height
    @colour = interface.colour

    @clear ||= Array.new(@height) do |iy|
      Array.new(@width) do |ix|
        Vedeu::Views::Char.new(value:    ' ',
                               colour:   @colour,
                               position: [@y + iy, @x + ix])
      end
    end
  end
end

#renderArray<Array<Vedeu::Views::Char>>



37
38
39
# File 'lib/vedeu/output/clear/named_interface.rb', line 37

def render
  output
end