Class: Vedeu::Clear::Interface
- Inherits:
-
Object
- Object
- Vedeu::Clear::Interface
- Includes:
- Vedeu::Common
- Defined in:
- lib/vedeu/output/clear/interface.rb
Overview
Clear the named interface.
Instance Attribute Summary collapse
- #name ⇒ String readonly protected
Class Method Summary collapse
-
.by_name ⇒ Array<Array<Vedeu::Views::Char>>
Clear the interface with the given name.
-
.clear_by_name ⇒ Array<Array<Vedeu::Views::Char>>
Clear the interface with the given name.
-
.clear_content_by_name(name = Vedeu.focus) ⇒ Array<Array<Vedeu::Views::Char>>
Clear the content of the interface with the given name.
-
.render(name = Vedeu.focus) ⇒ Array<Array<Vedeu::Views::Char>>
Clear the interface with the given name.
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Vedeu::Common
Returns a boolean indicating whether a variable is nil or empty.
- #border ⇒ Object private
- #clearing ⇒ String private
- #colour ⇒ Vedeu::Colours::Colour private
- #content_only? ⇒ Boolean private
- #defaults ⇒ Hash<Symbol => Boolean> private
-
#demodulize(klass) ⇒ String
included
from Vedeu::Common
Removes the module part from the expression in the string.
- #geometry ⇒ Object private
- #height ⇒ Fixnum private
-
#initialize(name, options = {}) ⇒ Vedeu::Clear::Interface
constructor
Return a new instance of Vedeu::Clear::Interface.
- #interface ⇒ Object private
- #options ⇒ Hash<Symbol => Boolean> private
-
#output ⇒ Array<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.
-
#present?(variable) ⇒ Boolean
included
from Vedeu::Common
Returns a boolean indicating whether a variable has a useful value.
- #render ⇒ Array<Array<Vedeu::Views::Char>>
-
#snake_case(name) ⇒ String
included
from Vedeu::Common
Converts a class name to a lowercase snake case string.
- #width ⇒ Fixnum private
- #x ⇒ Fixnum private
- #y ⇒ Fixnum private
Constructor Details
#initialize(name, options = {}) ⇒ Vedeu::Clear::Interface
Return a new instance of Vedeu::Clear::Interface.
53 54 55 56 |
# File 'lib/vedeu/output/clear/interface.rb', line 53 def initialize(name, = {}) @name = present?(name) ? name : Vedeu.focus = end |
Instance Attribute Details
#name ⇒ String (readonly, protected)
67 68 69 |
# File 'lib/vedeu/output/clear/interface.rb', line 67 def name @name end |
Class Method Details
.by_name ⇒ Array<Array<Vedeu::Views::Char>>
Clear the interface with the given name.
27 28 29 30 31 |
# File 'lib/vedeu/output/clear/interface.rb', line 27 def render(name = Vedeu.focus) name || Vedeu.focus new(name).render end |
.clear_by_name ⇒ Array<Array<Vedeu::Views::Char>>
Clear the interface with the given name.
26 27 28 29 30 |
# File 'lib/vedeu/output/clear/interface.rb', line 26 def render(name = Vedeu.focus) name || Vedeu.focus new(name).render end |
.clear_content_by_name(name = Vedeu.focus) ⇒ Array<Array<Vedeu::Views::Char>>
Clear the content of the interface with the given name.
37 38 39 40 41 |
# File 'lib/vedeu/output/clear/interface.rb', line 37 def clear_content_by_name(name = Vedeu.focus) name || Vedeu.focus new(name, content_only: true).render end |
.render(name = Vedeu.focus) ⇒ Array<Array<Vedeu::Views::Char>>
Clear the interface with the given name.
21 22 23 24 25 |
# File 'lib/vedeu/output/clear/interface.rb', line 21 def render(name = Vedeu.focus) name || Vedeu.focus new(name).render end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Vedeu::Common
Returns a boolean indicating whether a variable is nil or empty.
#border ⇒ Object (private)
72 73 74 |
# File 'lib/vedeu/output/clear/interface.rb', line 72 def border @border ||= Vedeu.borders.by_name(name) end |
#clearing ⇒ String (private)
140 141 142 143 144 |
# File 'lib/vedeu/output/clear/interface.rb', line 140 def clearing return 'content'.freeze if content_only? 'interface'.freeze end |
#colour ⇒ Vedeu::Colours::Colour (private)
77 78 79 |
# File 'lib/vedeu/output/clear/interface.rb', line 77 def colour interface.colour end |
#content_only? ⇒ Boolean (private)
82 83 84 |
# File 'lib/vedeu/output/clear/interface.rb', line 82 def content_only? [:content_only] end |
#defaults ⇒ Hash<Symbol => Boolean> (private)
87 88 89 90 91 |
# File 'lib/vedeu/output/clear/interface.rb', line 87 def defaults { content_only: false, } end |
#demodulize(klass) ⇒ String Originally defined in module Vedeu::Common
Removes the module part from the expression in the string.
#geometry ⇒ Object (private)
94 95 96 |
# File 'lib/vedeu/output/clear/interface.rb', line 94 def geometry @geometry ||= Vedeu.geometries.by_name(name) end |
#height ⇒ Fixnum (private)
99 100 101 102 103 |
# File 'lib/vedeu/output/clear/interface.rb', line 99 def height return border.height if content_only? geometry.height end |
#interface ⇒ Object (private)
106 107 108 |
# File 'lib/vedeu/output/clear/interface.rb', line 106 def interface @interface ||= Vedeu.interfaces.by_name(name) end |
#options ⇒ Hash<Symbol => Boolean> (private)
111 112 113 |
# File 'lib/vedeu/output/clear/interface.rb', line 111 def defaults.merge!() end |
#output ⇒ Array<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.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/vedeu/output/clear/interface.rb', line 121 def output Vedeu.timer("Clearing #{clearing}: '#{name}'".freeze) do @y = y @x = x @width = width @height = height @colour = colour @clear ||= Array.new(@height) do |iy| Array.new(@width) do |ix| Vedeu::Views::Char.new(value: ' '.freeze, colour: @colour, position: [@y + iy, @x + ix]) end end end end |
#present?(variable) ⇒ Boolean Originally defined in module Vedeu::Common
Returns a boolean indicating whether a variable has a useful value.
#render ⇒ Array<Array<Vedeu::Views::Char>>
59 60 61 |
# File 'lib/vedeu/output/clear/interface.rb', line 59 def render Vedeu.render_output(output) end |
#snake_case(name) ⇒ String Originally defined in module Vedeu::Common
Converts a class name to a lowercase snake case string.
#width ⇒ Fixnum (private)
147 148 149 150 151 |
# File 'lib/vedeu/output/clear/interface.rb', line 147 def width return border.width if content_only? geometry.width end |
#x ⇒ Fixnum (private)
161 162 163 164 165 |
# File 'lib/vedeu/output/clear/interface.rb', line 161 def x return border.bx if content_only? geometry.x end |
#y ⇒ Fixnum (private)
154 155 156 157 158 |
# File 'lib/vedeu/output/clear/interface.rb', line 154 def y return border.by if content_only? geometry.y end |