Class: Vedeu::Views::View
- Inherits:
-
Object
- Object
- Vedeu::Views::View
- Includes:
- Presentation, Repositories::Model
- Defined in:
- lib/vedeu/models/views/view.rb
Overview
Instance Attribute Summary collapse
- #attributes ⇒ Hash readonly
- #client ⇒ Fixnum|Float
- #cursor_visible ⇒ Boolean (also: #cursor_visible?)
- #lines ⇒ Array<Vedeu::Views::Line> writeonly
- #name ⇒ String
- #parent ⇒ Vedeu::Views::Composition
- #repository ⇒ Vedeu::Repositories::Repository included from Repositories::Model
- #zindex ⇒ Fixnum
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
- #add(child) ⇒ Vedeu::Views::Lines (also: #<<)
-
#background ⇒ Vedeu::Colours::Background
included
from Presentation::Colour
When the background colour for the model exists, return it, otherwise returns the parent background colour, or an empty Vedeu::Colours::Background.
-
#background=(value) ⇒ Vedeu::Colours::Background
included
from Presentation::Colour
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
- #colour ⇒ Vedeu::Colours::Colour included from Presentation::Colour
-
#colour=(value) ⇒ Vedeu::Colours::Colour
included
from Presentation::Colour
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
-
#defaults ⇒ Hash
private
The default values for a new instance of this class.
-
#demodulize(klass) ⇒ String
included
from Common
private
Removes the module part from the expression in the string.
-
#deputy(client = nil) ⇒ Vedeu::DSL::View
Returns a DSL instance responsible for defining the DSL methods of this model.
-
#foreground ⇒ Vedeu::Colours::Foreground
included
from Presentation::Colour
When the foreground colour for the model exists, return it, otherwise returns the parent foreground colour, or an empty Vedeu::Colours::Foreground.
-
#foreground=(value) ⇒ Vedeu::Colours::Foreground
included
from Presentation::Colour
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
-
#initialize(attributes = {}) ⇒ Vedeu::Views::View
constructor
Return a new instance of Vedeu::Views::View.
-
#position? ⇒ Boolean
included
from Presentation
private
Returns a boolean indicating the model has a position attribute.
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#render_colour ⇒ String
included
from Presentation
private
Renders the colour attributes of the receiver and yields (to then render the styles).
- #render_position ⇒ String included from Presentation private
-
#render_style ⇒ String
included
from Presentation
private
Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).
-
#snake_case(name) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#store ⇒ void
included
from Repositories::Model
The model instance stored in the repository.
-
#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.
-
#style ⇒ Vedeu::Presentation::Style
included
from Presentation::Styles
When the style for the model exists, return it, otherwise returns the parent style, or an empty Presentation::Style.
-
#style=(value) ⇒ Vedeu::Presentation::Style
included
from Presentation::Styles
Allows the setting of the style by coercing the given value into a Presentation::Style.
-
#to_s ⇒ String
(also: #to_str)
included
from Presentation
Converts the colours and styles to escape sequences, and when the parent model has previously set the colour and style, reverts back to that for consistent formatting.
- #value ⇒ Vedeu::Views::Lines (also: #lines)
-
#visible? ⇒ Boolean
Returns a boolean indicating whether the view is visible.
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Views::View
Return a new instance of Vedeu::Views::View.
65 66 67 68 69 70 71 |
# File 'lib/vedeu/models/views/view.rb', line 65 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)
26 27 28 |
# File 'lib/vedeu/models/views/view.rb', line 26 def attributes @attributes end |
#client ⇒ Fixnum|Float
30 31 32 |
# File 'lib/vedeu/models/views/view.rb', line 30 def client @client end |
#cursor_visible ⇒ Boolean Also known as: cursor_visible?
34 35 36 |
# File 'lib/vedeu/models/views/view.rb', line 34 def cursor_visible @cursor_visible end |
#lines=(value) ⇒ Array<Vedeu::Views::Line> (writeonly)
47 48 49 |
# File 'lib/vedeu/models/views/view.rb', line 47 def lines=(value) @lines = value end |
#name ⇒ String
39 40 41 |
# File 'lib/vedeu/models/views/view.rb', line 39 def name @name end |
#parent ⇒ Vedeu::Views::Composition
43 44 45 |
# File 'lib/vedeu/models/views/view.rb', line 43 def parent @parent end |
#repository ⇒ Vedeu::Repositories::Repository Originally defined in module Repositories::Model
#zindex ⇒ Fixnum
51 52 53 |
# File 'lib/vedeu/models/views/view.rb', line 51 def zindex @zindex end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Common
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 boolean indicating whether a variable is nil or empty.
#add(child) ⇒ Vedeu::Views::Lines Also known as: <<
75 76 77 |
# File 'lib/vedeu/models/views/view.rb', line 75 def add(child) @value = value.add(child) end |
#background ⇒ Vedeu::Colours::Background Originally defined in module Presentation::Colour
When the background colour for the model exists, return it, otherwise returns the parent background colour, or an empty Vedeu::Colours::Background.
#background=(value) ⇒ Vedeu::Colours::Background Originally defined in module Presentation::Colour
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
#colour ⇒ Vedeu::Colours::Colour Originally defined in module Presentation::Colour
#colour=(value) ⇒ Vedeu::Colours::Colour Originally defined in module Presentation::Colour
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
#defaults ⇒ Hash (private)
The default values for a new instance of this class.
138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/vedeu/models/views/view.rb', line 138 def defaults { client: nil, colour: Vedeu::Configuration.colour, cursor_visible: true, name: '', parent: nil, style: :normal, value: [], zindex: 0, } end |
#demodulize(klass) ⇒ String Originally defined in module Common
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.
Removes the module part from the expression in the string.
#deputy(client = nil) ⇒ Vedeu::DSL::View
Returns a DSL instance responsible for defining the DSL methods of this model.
88 89 90 |
# File 'lib/vedeu/models/views/view.rb', line 88 def deputy(client = nil) Vedeu::DSL::View.new(self, client) end |
#foreground ⇒ Vedeu::Colours::Foreground Originally defined in module Presentation::Colour
When the foreground colour for the model exists, return it, otherwise returns the parent foreground colour, or an empty Vedeu::Colours::Foreground.
#foreground=(value) ⇒ Vedeu::Colours::Foreground Originally defined in module Presentation::Colour
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
#position? ⇒ Boolean (private) Originally defined in module Presentation
Returns a boolean indicating the model has a position attribute.
#present?(variable) ⇒ Boolean Originally defined in module Common
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 boolean indicating whether a variable has a useful value.
#render_colour ⇒ String (private) Originally defined in module Presentation
Renders the colour attributes of the receiver and yields (to then render the styles).
#render_position ⇒ String (private) Originally defined in module Presentation
#render_style ⇒ String (private) Originally defined in module Presentation
Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).
#snake_case(name) ⇒ String Originally defined in module Common
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.
Converts a class name to a lowercase snake case string.
#store ⇒ void Originally defined in module Repositories::Model
Perhaps some validation could be added here?
If a block is given, store the model, return the model after yielding.
This method returns an undefined value.
Returns The model instance stored in the repository.
#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.
116 117 118 119 120 121 122 123 124 |
# File 'lib/vedeu/models/views/view.rb', line 116 def store_deferred fail Vedeu::Error::InvalidSyntax, 'Cannot store an interface ' \ 'without a name.'.freeze 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.
102 103 104 105 106 107 108 |
# File 'lib/vedeu/models/views/view.rb', line 102 def store_immediate store_deferred Vedeu.trigger(:_refresh_view_, name) self end |
#style ⇒ Vedeu::Presentation::Style Originally defined in module Presentation::Styles
When the style for the model exists, return it, otherwise returns the parent style, or an empty Vedeu::Presentation::Style.
#style=(value) ⇒ Vedeu::Presentation::Style Originally defined in module Presentation::Styles
Allows the setting of the style by coercing the given value into a Vedeu::Presentation::Style.
#to_s ⇒ String Also known as: to_str Originally defined in module Presentation
Converts the colours and styles to escape sequences, and when the parent model has previously set the colour and style, reverts back to that for consistent formatting.
#value ⇒ Vedeu::Views::Lines Also known as: lines
93 94 95 |
# File 'lib/vedeu/models/views/view.rb', line 93 def value collection.coerce(@value, self) end |
#visible? ⇒ Boolean
Returns a boolean indicating whether the view is visible.
129 130 131 |
# File 'lib/vedeu/models/views/view.rb', line 129 def visible? Vedeu.interfaces.by_name(name).visible? end |