Class: Vedeu::DSL::View
- Inherits:
-
Object
- Object
- Vedeu::DSL::View
- Includes:
- Common, Vedeu::DSL
- Defined in:
- lib/vedeu/dsl/view.rb
Overview
-
A view (
View) is made up of one or more interfaces. -
An interface is an area on the screen where you can take input or direct output. You will define it’s colour and style, its dimensions, including position and give it a name. You can then direct the output of a command, or event, to this interface and Vedeu will ensure the content is placed there.
-
Interfaces (
Interface) are made up of lines (Line), their length being the width of the interface and their number being the height of the interface. -
An interface with ‘width: 12, height: 5` will have five lines, each made of 12 characters- providing 60 cells. Colours and styles are handled by terminal escape sequences and therefore do not consume a cell.
-
Lines are made up of zero, one or multiple streams which are basically subsets of the line.
-
An interface, line or stream can have a colour attribute.
-
An interface, line or stream can have a style attribute.
-
Interfaces have a position (
y,x) on the screen, and a size. (width,height) -
Interfaces can be placed relative to each other based on their attributes.
-
An interface has a
top,right,bottom,left. -
An interface also has a
northandwest(topandleftminus 1 respectively). -
An interface also has a
southandeast(bottomandrightplus 1 respectively).
-
-
Colours are defined in CSS-style values, i.e.
#ff0000would be red. -
Styles are named. See the table below for supported styles.
Instance Attribute Summary
Attributes included from Vedeu::DSL
Instance Method Summary collapse
-
#existing_attributes(name) ⇒ Hash<Symbol => void>
private
Retrieve the attributes of the interface by name.
-
#interface(name) ⇒ Vedeu::Interfaces::Interface
private
Returns the named interface/view from the interfaces repository.
-
#new_attributes(name) ⇒ Hash<Symbol => void>
private
Return the current attributes combined with the existing interface attributes defined by the interface.
- #template_attributes(name, lines) ⇒ Hash<Symbol => void> private
-
#template_for(name, filename, object = nil, options = {}) ⇒ Vedeu::Views::Views<Vedeu::Views::View>
-
#view(name, &block) ⇒ Vedeu::Views::Views<Vedeu::Views::View>
Methods included from Vedeu::DSL
#attributes, #initialize, #method_missing, #name
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?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vedeu::DSL
Instance Method Details
#existing_attributes(name) ⇒ Hash<Symbol => void> (private)
Retrieve the attributes of the interface by name.
122 123 124 |
# File 'lib/vedeu/dsl/view.rb', line 122 def existing_attributes(name) interface(name).attributes end |
#interface(name) ⇒ Vedeu::Interfaces::Interface (private)
Returns the named interface/view from the interfaces repository.
127 128 129 |
# File 'lib/vedeu/dsl/view.rb', line 127 def interface(name) Vedeu.interfaces.by_name(name) end |
#new_attributes(name) ⇒ Hash<Symbol => void> (private)
Return the current attributes combined with the existing interface attributes defined by the interface.
114 115 116 |
# File 'lib/vedeu/dsl/view.rb', line 114 def new_attributes(name) existing_attributes(name).merge!(attributes) end |
#template_attributes(name, lines) ⇒ Hash<Symbol => void> (private)
105 106 107 |
# File 'lib/vedeu/dsl/view.rb', line 105 def template_attributes(name, lines) new_attributes(name).merge!(value: lines) end |
#template_for(name, filename, object = nil, options = {}) ⇒ Vedeu::Views::Views<Vedeu::Views::View>
More documentation required.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/vedeu/dsl/view.rb', line 79 def template_for(name, filename, object = nil, = {}) raise Vedeu::Error::MissingRequired, 'Cannot render template without the name of the ' \ 'view.' unless present?(name) raise Vedeu::Error::MissingRequired, 'Cannot render template without a ' \ 'filename.' unless present?(filename) [:name] = name content = Vedeu::Templating::ViewTemplate.parse(object, filename, ) # lines = Vedeu::DSL::Wordwrap.for(content, options) new_model = Vedeu::Views::View.build(template_attributes(name, content)) model.add(new_model) end |
#view(name, &block) ⇒ Vedeu::Views::Views<Vedeu::Views::View>
More documentation required.
57 58 59 60 61 62 63 64 65 |
# File 'lib/vedeu/dsl/view.rb', line 57 def view(name, &block) raise Vedeu::Error::RequiresBlock unless block_given? raise Vedeu::Error::MissingRequired, 'Cannot add view without a name.' unless present?(name) new_model = Vedeu::Views::View.build(new_attributes(name), &block) model.add(new_model) end |