Class: Vedeu::API::Interface
- Includes:
- Helpers
- Defined in:
- lib/vedeu/api/interface.rb
Instance Attribute Summary
Attributes inherited from Interface
Instance Method Summary collapse
-
#centred(value) ⇒ Object
Instructs Vedeu to calculate x and y geometry automatically based on the centre character of the terminal, the width and the height.
-
#cursor(value) ⇒ Object
Define the cursor visibility for an interface.
-
#delay(value) ⇒ Object
To maintain performance interfaces can be delayed from refreshing too often, the reduces artefacts particularly when resizing the terminal screen.
-
#group(value) ⇒ Object
Define a group for an interface.
-
#height(value) ⇒ Object
Define the number of characters/rows/lines tall the interface will be.
-
#line(value = '', &block) ⇒ Object
Define a single line in a view.
-
#name(value) ⇒ Object
The name of the interface.
-
#use(value) ⇒ Object
Use the specified interface; useful for sharing attributes with other interfaces.
-
#width(value) ⇒ Object
Define the number of characters/columns wide the interface will be.
-
#x(value = 0, &block) ⇒ Object
Define the starting x position (column) of the interface.
-
#y(value = 0, &block) ⇒ Object
Define the starting y position (row/line) of the interface.
Methods included from Helpers
Methods inherited from Interface
build, #clear, #defaults, #define, define, #geometry, #initialize, #lines, #method_missing, #out_of_bounds, #to_s, #x_out_of_bounds?, #y_out_of_bounds?
Methods included from Presentation
Methods included from Coercions
Constructor Details
This class inherits a constructor from Vedeu::Interface
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vedeu::Interface
Instance Method Details
#centred(value) ⇒ Object
Instructs Vedeu to calculate x and y geometry automatically based on the centre character of the terminal, the width and the height.
205 206 207 208 209 210 211 |
# File 'lib/vedeu/api/interface.rb', line 205 def centred(value) unless value.is_a?(TrueClass) || value.is_a?(FalseClass) fail InvalidSyntax, 'Argument must be `true` or `false` for centred.' end attributes[:geometry][:centred] = value end |
#cursor(value) ⇒ Object
Define the cursor visibility for an interface. A ‘true` value will show the cursor, whilst `false` will hide it.
57 58 59 60 61 62 63 |
# File 'lib/vedeu/api/interface.rb', line 57 def cursor(value) unless value.is_a?(TrueClass) || value.is_a?(FalseClass) fail InvalidSyntax, 'Argument must be `true` or `false` for cursor.' end attributes[:cursor] = value end |
#delay(value) ⇒ Object
To maintain performance interfaces can be delayed from refreshing too often, the reduces artefacts particularly when resizing the terminal screen.
73 74 75 |
# File 'lib/vedeu/api/interface.rb', line 73 def delay(value) attributes[:delay] = value end |
#group(value) ⇒ Object
Define 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.
90 91 92 |
# File 'lib/vedeu/api/interface.rb', line 90 def group(value) attributes[:group] = value end |
#height(value) ⇒ Object
Define the number of characters/rows/lines tall the interface will be.
187 188 189 190 191 |
# File 'lib/vedeu/api/interface.rb', line 187 def height(value) Vedeu.log(out_of_bounds('height')) if y_out_of_bounds?(value) attributes[:geometry][:height] = value end |
#line(value = '', &block) ⇒ Object
Define a single line in a view.
25 26 27 28 29 30 31 32 33 |
# File 'lib/vedeu/api/interface.rb', line 25 def line(value = '', &block) if block_given? attributes[:lines] << Line.build(&block) else attributes[:lines] << Line.build({ streams: { text: value } }) end end |
#name(value) ⇒ Object
The name of the interface. Used to reference the interface throughout your application’s execution lifetime.
106 107 108 |
# File 'lib/vedeu/api/interface.rb', line 106 def name(value) attributes[:name] = value end |
#use(value) ⇒ Object
Use the specified interface; useful for sharing attributes with other interfaces.
41 42 43 |
# File 'lib/vedeu/api/interface.rb', line 41 def use(value) Vedeu.use(value) end |
#width(value) ⇒ Object
Define the number of characters/columns wide the interface will be.
170 171 172 173 174 |
# File 'lib/vedeu/api/interface.rb', line 170 def width(value) Vedeu.log(out_of_bounds('width')) if x_out_of_bounds?(value) attributes[:geometry][:width] = value end |
#x(value = 0, &block) ⇒ Object
Define the starting x position (column) of the interface.
126 127 128 129 130 131 132 |
# File 'lib/vedeu/api/interface.rb', line 126 def x(value = 0, &block) return attributes[:geometry][:x] = block if block_given? Vedeu.log(out_of_bounds('x')) if x_out_of_bounds?(value) attributes[:geometry][:x] = value end |
#y(value = 0, &block) ⇒ Object
Define the starting y position (row/line) of the interface.
151 152 153 154 155 156 157 |
# File 'lib/vedeu/api/interface.rb', line 151 def y(value = 0, &block) return attributes[:geometry][:y] = block if block_given? Vedeu.log(out_of_bounds('y')) if y_out_of_bounds?(value) attributes[:geometry][:y] = value end |