Class: Vedeu::DSL::Interface
- Inherits:
-
Object
- Object
- Vedeu::DSL::Interface
- Includes:
- Common, Vedeu::DSL, Presentation, Text, Use
- Defined in:
- lib/vedeu/dsl/interface.rb
Overview
DSL for creating interfaces.
Instance Attribute Summary collapse
- #client ⇒ Object readonly protected
- #model ⇒ Interface readonly protected
Instance Method Summary collapse
- #attributes ⇒ Hash private
-
#border(name = nil, &block) ⇒ Vedeu::Border
Allows the setting of a border for the interface.
-
#border! ⇒ Vedeu::Border
Applies the default border to the interface.
-
#cursor(value = true) ⇒ Cursor
Set the cursor visibility on an interface.
-
#cursor! ⇒ Vedeu::Cursor
Set the cursor to visible for the interface.
-
#delay(value) ⇒ Fixnum|Float
To maintain performance interfaces can be delayed from refreshing too often, the reduces artefacts particularly when resizing the terminal screen.
-
#focus! ⇒ String
Specify this interface as being in focus when the application starts.
-
#geometry(name = nil, &block) ⇒ Geometry
Define the geometry for an interface.
-
#group(name) ⇒ Vedeu::Group
Specify a group for an interface.
-
#hide! ⇒ void
Set the interface to invisible.
-
#initialize(model, client = nil) ⇒ Vedeu::DSL::Interface
constructor
Returns an instance of Vedeu::DSL::Interface.
- #keymap(name = model.name, &block) ⇒ Object (also: #keys)
-
#lines(&block) ⇒ Line
(also: #line)
Specify multiple lines in a view.
-
#name(value) ⇒ String
The name of the interface.
-
#show! ⇒ void
Set the interface to visible.
-
#visible(value = true) ⇒ void
Set the visibility of the interface.
Methods included from Use
Methods included from Text
Methods included from Presentation
#background, #colour, #foreground, #style
Methods included from Vedeu::DSL
Methods included from Common
Constructor Details
#initialize(model, client = nil) ⇒ Vedeu::DSL::Interface
Returns an instance of Vedeu::DSL::Interface.
19 20 21 22 |
# File 'lib/vedeu/dsl/interface.rb', line 19 def initialize(model, client = nil) @model = model @client = client end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vedeu::DSL
Instance Attribute Details
#client ⇒ Object (readonly, protected)
245 246 247 |
# File 'lib/vedeu/dsl/interface.rb', line 245 def client @client end |
#model ⇒ Interface (readonly, protected)
249 250 251 |
# File 'lib/vedeu/dsl/interface.rb', line 249 def model @model end |
Instance Method Details
#attributes ⇒ Hash (private)
254 255 256 257 258 259 |
# File 'lib/vedeu/dsl/interface.rb', line 254 def attributes { client: client, parent: model, } end |
#border(name = nil, &block) ⇒ Vedeu::Border
Allows the setting of a border for the interface.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vedeu/dsl/interface.rb', line 32 def border(name = nil, &block) fail InvalidSyntax, 'block not given' unless block_given? model_name = name ? name : model.name border_attrs = attributes.merge!(enabled: true, name: model_name) Vedeu::Border.build(border_attrs, &block).store end |
#border! ⇒ Vedeu::Border
Applies the default border to the interface.
46 47 48 49 50 |
# File 'lib/vedeu/dsl/interface.rb', line 46 def border! border do # adds default border end end |
#cursor(value = true) ⇒ Cursor
Set the cursor visibility on an interface.
73 74 75 76 77 |
# File 'lib/vedeu/dsl/interface.rb', line 73 def cursor(value = true) boolean = value ? true : false Vedeu::Cursor.new(name: model.name, visible: boolean).store end |
#cursor! ⇒ Vedeu::Cursor
Set the cursor to visible for the interface.
82 83 84 |
# File 'lib/vedeu/dsl/interface.rb', line 82 def cursor! cursor(true) end |
#delay(value) ⇒ Fixnum|Float
To maintain performance interfaces can be delayed from refreshing too often, the reduces artefacts particularly when resizing the terminal screen.
98 99 100 |
# File 'lib/vedeu/dsl/interface.rb', line 98 def delay(value) model.delay = value end |
#focus! ⇒ String
If multiple interfaces are defined, and this is included in each, then the last defined will be the interface in focus.
Specify this interface as being in focus when the application starts.
108 109 110 |
# File 'lib/vedeu/dsl/interface.rb', line 108 def focus! Vedeu::Focus.add(model.name, true) if defined_value?(model.name) end |
#geometry(name = nil, &block) ⇒ Geometry
Define the geometry for an interface.
126 127 128 129 130 131 132 |
# File 'lib/vedeu/dsl/interface.rb', line 126 def geometry(name = nil, &block) fail InvalidSyntax, 'block not given' unless block_given? model_name = name ? name : model.name Vedeu::Geometry.build({ name: model_name }, &block).store end |
#group(name) ⇒ Vedeu::Group
Specify a group for an interface. Interfaces of the same group can be targetted together; for example you may want to refresh multiple interfaces at once.
146 147 148 149 150 151 152 |
# File 'lib/vedeu/dsl/interface.rb', line 146 def group(name) return false unless defined_value?(name) model.group = name Vedeu.groups.by_name(name).add(model.name) end |
#hide! ⇒ void
This method returns an undefined value.
Set the interface to invisible.
211 212 213 |
# File 'lib/vedeu/dsl/interface.rb', line 211 def hide! visible(false) end |
#keymap(name = model.name, &block) ⇒ Object Also known as: keys
155 156 157 |
# File 'lib/vedeu/dsl/interface.rb', line 155 def keymap(name = model.name, &block) Vedeu.keymap(name, &block) end |
#lines(&block) ⇒ Line Also known as: line
Specify multiple lines in a view.
179 180 181 182 183 |
# File 'lib/vedeu/dsl/interface.rb', line 179 def lines(&block) fail InvalidSyntax, 'block not given' unless block_given? model.add(model.member.build(attributes, &block)) end |
#name(value) ⇒ String
The name of the interface. Used to reference the interface throughout your application’s execution lifetime.
197 198 199 |
# File 'lib/vedeu/dsl/interface.rb', line 197 def name(value) model.name = value end |
#show! ⇒ void
This method returns an undefined value.
Set the interface to visible.
204 205 206 |
# File 'lib/vedeu/dsl/interface.rb', line 204 def show! visible(true) end |
#visible(value = true) ⇒ void
This method returns an undefined value.
Set the visibility of the interface.
235 236 237 238 239 |
# File 'lib/vedeu/dsl/interface.rb', line 235 def visible(value = true) boolean = value ? true : false model.visible = boolean end |