Class: Vedeu::DSL::View
- Inherits:
-
Object
- Object
- Vedeu::DSL::View
- Defined in:
- lib/vedeu/dsl/view.rb
Overview
DSL for creating views.
Class Method Summary collapse
-
.client(&block) ⇒ Object
private
Returns the client object which called the DSL method.
-
.composition(client, &block) ⇒ Vedeu::Composition
private
Creates a new Composition which may contain one or more views (Interface objects).
-
.interface(name = '', &block) ⇒ Interface
Register an interface by name which will display output from a event or command.
-
.renders(&block) ⇒ Array<Interface>
Immediate render.
-
.store(method, &block) ⇒ Array
private
Stores each of the views defined in their respective buffers ready to be rendered on next refresh.
-
.views(&block) ⇒ Array<Interface>
Deferred view.
Class Method Details
.client(&block) ⇒ Object (private)
Returns the client object which called the DSL method.
103 104 105 |
# File 'lib/vedeu/dsl/view.rb', line 103 def client(&block) eval('self', block.binding) end |
.composition(client, &block) ⇒ Vedeu::Composition (private)
Creates a new Composition which may contain one or more views (Interface objects).
113 114 115 |
# File 'lib/vedeu/dsl/view.rb', line 113 def composition(client, &block) Vedeu::Composition.build({ client: client }, &block) end |
.interface(name = '', &block) ⇒ Interface
More documentation required.
Register an interface by name which will display output from a event or command. This provides the means for you to define your the views of your application without their content.
36 37 38 39 40 41 42 |
# File 'lib/vedeu/dsl/view.rb', line 36 def interface(name = '', &block) fail InvalidSyntax, 'block not given' unless block_given? attributes = { client: client(&block), name: name } Vedeu::Interface.build(attributes, &block).store end |
.renders(&block) ⇒ Array<Interface>
Immediate render
Directly write a view buffer to the terminal. Using this method means that the refresh event does not need to be triggered after creating the views, though can be later triggered if needed.
60 61 62 63 64 |
# File 'lib/vedeu/dsl/view.rb', line 60 def renders(&block) fail InvalidSyntax, 'block not given' unless block_given? store(:store_immediate, &block) end |
.store(method, &block) ⇒ Array (private)
Stores each of the views defined in their respective buffers ready to be rendered on next refresh.
125 126 127 128 129 |
# File 'lib/vedeu/dsl/view.rb', line 125 def store(method, &block) composition(client(&block), &block).interfaces.map do |interface| interface.public_send(method) end end |
.views(&block) ⇒ Array<Interface>
The views declared within this block are stored in their respective interface back buffers until a refresh event occurs. When the refresh event is triggered, the back buffers are swapped into the front buffers and the content here will be rendered to Terminal.output.
Deferred view
Define a view (content) for an interface.
91 92 93 94 95 |
# File 'lib/vedeu/dsl/view.rb', line 91 def views(&block) fail InvalidSyntax, 'block not given' unless block_given? store(:store_deferred, &block) end |