Class: Vedeu::Views::View
- Inherits:
-
Object
- Object
- Vedeu::Views::View
- Extended by:
- Forwardable
- Includes:
- Presentation, Repositories::Model, Value
- Defined in:
- lib/vedeu/views/view.rb
Overview
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
- #cursor_visible ⇒ Boolean (also: #cursor_visible?)
- #name ⇒ NilClass|String|Symbol
- #wordwrap ⇒ Boolean (also: #wordwrap?)
- #zindex ⇒ Fixnum
Attributes included from Repositories::Model
Instance Method Summary collapse
-
#add(child) ⇒ Vedeu::Views::Lines
(also: #<<)
Adds the child to the collection.
- #attributes ⇒ Hash
- #buffer ⇒ Vedeu::Buffers::Buffer private
-
#defaults ⇒ Hash<Symbol => void>
private
The default options/attributes for a new instance of this class.
-
#initialize(attributes = {}) ⇒ Vedeu::Views::View
constructor
Return a new instance of Vedeu::Views::View.
- #interface ⇒ Vedeu::Interfaces::Interface private
- #parent ⇒ NilClass|void
-
#update_buffer(refresh = false) ⇒ Vedeu::Views::View
Store the view in its respective buffer.
-
#visible? ⇒ Boolean
Returns a boolean indicating whether the view is visible.
Methods included from Value
Methods included from Presentation
Methods included from Presentation::Styles
#render_style, #style, #style=
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?
Methods included from Presentation::Position
#position, #position=, #position?, #render_position, #x, #y
Methods included from Presentation::Colour
#background, #background=, #colour, #colour=, #colour?, #foreground, #foreground=, #named_colour, #named_colour?, #parent_colour, #parent_colour?, #render_colour
Methods included from Repositories::Model
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Views::View
Return a new instance of Vedeu::Views::View.
75 76 77 78 79 |
# File 'lib/vedeu/views/view.rb', line 75 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#cursor_visible ⇒ Boolean Also known as: cursor_visible?
46 47 48 |
# File 'lib/vedeu/views/view.rb', line 46 def cursor_visible @cursor_visible end |
#name ⇒ NilClass|String|Symbol
51 52 53 |
# File 'lib/vedeu/views/view.rb', line 51 def name @name end |
#wordwrap ⇒ Boolean Also known as: wordwrap?
55 56 57 |
# File 'lib/vedeu/views/view.rb', line 55 def wordwrap @wordwrap end |
#zindex ⇒ Fixnum
60 61 62 |
# File 'lib/vedeu/views/view.rb', line 60 def zindex @zindex end |
Instance Method Details
#add(child) ⇒ Vedeu::Views::Lines Also known as: <<
Adds the child to the collection.
85 86 87 |
# File 'lib/vedeu/views/view.rb', line 85 def add(child) @value = value.add(child) end |
#attributes ⇒ Hash
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/vedeu/views/view.rb', line 91 def attributes { client: client, colour: colour, cursor_visible: cursor_visible, name: name, parent: parent, style: style, value: value, wordwrap: wordwrap, zindex: zindex, } end |
#buffer ⇒ Vedeu::Buffers::Buffer (private)
150 151 152 |
# File 'lib/vedeu/views/view.rb', line 150 def buffer Vedeu.buffers.by_name(name) end |
#defaults ⇒ Hash<Symbol => void> (private)
The default options/attributes for a new instance of this class.
155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/vedeu/views/view.rb', line 155 def defaults { client: nil, colour: Vedeu.config.colour, cursor_visible: true, name: nil, parent: nil, style: :normal, value: [], wordwrap: true, zindex: 0, } end |
#interface ⇒ Vedeu::Interfaces::Interface (private)
170 171 172 |
# File 'lib/vedeu/views/view.rb', line 170 def interface Vedeu.interfaces.by_name(name) end |
#parent ⇒ NilClass|void
117 118 119 |
# File 'lib/vedeu/views/view.rb', line 117 def parent present?(@parent) ? @parent : nil end |
#update_buffer(refresh = false) ⇒ Vedeu::Views::View
Store the view in its respective buffer.
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/vedeu/views/view.rb', line 127 def update_buffer(refresh = false) if present?(name) buffer.add(self, refresh) else raise Vedeu::Error::MissingRequired, 'Cannot store a view without a name.' end self end |
#visible? ⇒ Boolean
Returns a boolean indicating whether the view is visible.
143 144 145 |
# File 'lib/vedeu/views/view.rb', line 143 def visible? interface.visible? end |