Class: Vedeu::Clear Private

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/output/clear.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.

Clears all the character data for the area defined by an interface. This class is called every time an interface is rendered to prepare the area for new data.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(interface) ⇒ Clear

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

Parameters:



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

def initialize(interface)
  @interface = interface
end

Instance Attribute Details

#interfaceObject (readonly, 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.



41
42
43
# File 'lib/vedeu/output/clear.rb', line 41

def interface
  @interface
end

Class Method Details

.call(interface) ⇒ String

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.

Blanks the area defined by the interface.

Parameters:

Returns:

  • (String)


14
15
16
# File 'lib/vedeu/output/clear.rb', line 14

def self.call(interface)
  new(interface).clear
end

Instance Method Details

#clearString

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:

  • (String)


31
32
33
34
35
36
37
# File 'lib/vedeu/output/clear.rb', line 31

def clear
  Vedeu.log("Clearing view: '#{interface.name}'")

  rows.inject([colours]) do |line, index|
    line << interface.origin(index) { ' ' * interface.viewport_width }
  end.join
end

#coloursString (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)


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

def colours
  interface.colour.to_s
end

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

  • (Enumerator)


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

def rows
  interface.viewport_height.times
end