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.
100 101 102 |
# File 'lib/vedeu/dsl/view.rb', line 100 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).
110 111 112 |
# File 'lib/vedeu/dsl/view.rb', line 110 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.
33 34 35 36 37 38 39 |
# File 'lib/vedeu/dsl/view.rb', line 33 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.
57 58 59 60 61 |
# File 'lib/vedeu/dsl/view.rb', line 57 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.
122 123 124 125 126 |
# File 'lib/vedeu/dsl/view.rb', line 122 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.
88 89 90 91 92 |
# File 'lib/vedeu/dsl/view.rb', line 88 def views(&block) fail InvalidSyntax, 'block not given' unless block_given? store(:store_deferred, &block) end |