Class: Vedeu::Views::View
- Inherits:
-
Object
- Object
- Vedeu::Views::View
- Includes:
- Model, Presentation
- Defined in:
- lib/vedeu/models/views/view.rb
Overview
Instance Attribute Summary collapse
- #attributes ⇒ Hash readonly
- #client ⇒ Fixnum|Float
- #lines ⇒ Array<Vedeu::Views::Line> writeonly
- #name ⇒ String
- #parent ⇒ Vedeu::Views::Composition
- #zindex ⇒ Fixnum
Attributes included from Model
Instance Method Summary collapse
- #add(child) ⇒ Vedeu::Views::Lines (also: #<<)
-
#defaults ⇒ Hash
private
The default values for a new instance of this class.
-
#initialize(attributes = {}) ⇒ Vedeu::Views::View
constructor
Return a new instance of Vedeu::Views::View.
- #render ⇒ Array<Array<Vedeu::Views::Char>>
-
#store_deferred ⇒ Vedeu::Views::View
When a name is given, the view is stored with this name.
-
#store_immediate ⇒ Vedeu::Views::View
Store the view and immediately refresh it; causing to be pushed to the Terminal.
- #value ⇒ Vedeu::Views::Lines (also: #lines)
-
#visible? ⇒ Boolean
Returns a boolean indicating whether the view is visible.
Methods included from Presentation
#render_colour, #render_position, #render_style, #to_s
Methods included from Presentation::Styles
Methods included from Presentation::Colour
#background, #background=, #colour, #colour=, #foreground, #foreground=
Methods included from Model
#deputy, #dsl_class, included, #store
Methods included from Common
#demodulize, #present?, #snake_case
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Views::View
Return a new instance of Vedeu::Views::View.
51 52 53 54 55 56 57 |
# File 'lib/vedeu/models/views/view.rb', line 51 def initialize(attributes = {}) @attributes = defaults.merge!(attributes) @attributes.each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#attributes ⇒ Hash (readonly)
18 19 20 |
# File 'lib/vedeu/models/views/view.rb', line 18 def attributes @attributes end |
#client ⇒ Fixnum|Float
22 23 24 |
# File 'lib/vedeu/models/views/view.rb', line 22 def client @client end |
#lines=(value) ⇒ Array<Vedeu::Views::Line> (writeonly)
34 35 36 |
# File 'lib/vedeu/models/views/view.rb', line 34 def lines=(value) @lines = value end |
#name ⇒ String
26 27 28 |
# File 'lib/vedeu/models/views/view.rb', line 26 def name @name end |
#parent ⇒ Vedeu::Views::Composition
30 31 32 |
# File 'lib/vedeu/models/views/view.rb', line 30 def parent @parent end |
#zindex ⇒ Fixnum
38 39 40 |
# File 'lib/vedeu/models/views/view.rb', line 38 def zindex @zindex end |
Instance Method Details
#add(child) ⇒ Vedeu::Views::Lines Also known as: <<
61 62 63 |
# File 'lib/vedeu/models/views/view.rb', line 61 def add(child) @value = value.add(child) end |
#defaults ⇒ Hash (private)
The default values for a new instance of this class.
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/vedeu/models/views/view.rb', line 126 def defaults { client: nil, colour: Vedeu::Colours::Colour.coerce(background: :default, foreground: :default), name: '', parent: nil, style: :normal, value: [], zindex: 0, } end |
#render ⇒ Array<Array<Vedeu::Views::Char>>
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vedeu/models/views/view.rb', line 73 def render return [] unless visible? output = [ Vedeu::Cursors::Cursor.hide_cursor(name), Vedeu::Clear::NamedInterface.render(name), Vedeu::Output::Viewport.render(self), Vedeu.borders.by_name(name).render, Vedeu::Cursors::Cursor.show_cursor(name), ] output end |
#store_deferred ⇒ Vedeu::Views::View
When a name is given, the view is stored with this name. This view will be shown next time a refresh event is triggered with this name. Called by DSL::View.views.
105 106 107 108 109 110 111 112 |
# File 'lib/vedeu/models/views/view.rb', line 105 def store_deferred fail Vedeu::Error::InvalidSyntax, 'Cannot store an interface without a name.' unless present?(name) Vedeu.buffers.by_name(name).add(self) self end |
#store_immediate ⇒ Vedeu::Views::View
Store the view and immediately refresh it; causing to be pushed to the Terminal. Called by DSL::View.renders.
91 92 93 94 95 96 97 |
# File 'lib/vedeu/models/views/view.rb', line 91 def store_immediate store_deferred Vedeu.trigger(:_refresh_, name) self end |
#value ⇒ Vedeu::Views::Lines Also known as: lines
67 68 69 |
# File 'lib/vedeu/models/views/view.rb', line 67 def value collection.coerce(@value, self) end |
#visible? ⇒ Boolean
Returns a boolean indicating whether the view is visible.
117 118 119 |
# File 'lib/vedeu/models/views/view.rb', line 117 def visible? Vedeu.interfaces.by_name(name).visible? end |