Class: Vedeu::DSL::Geometry
- Inherits:
-
Object
- Object
- Vedeu::DSL::Geometry
- Includes:
- Vedeu::DSL, Use
- Defined in:
- lib/vedeu/dsl/components/geometry.rb
Overview
Provide DSL methods for configuring the geometry of an interface.
Instance Attribute Summary collapse
- #client ⇒ Object readonly protected
- #model ⇒ Geometry readonly protected
Class Method Summary collapse
-
.geometry(name, &block) ⇒ Vedeu::Geometry
Specify the geometry of an interface or view with a simple DSL.
Instance Method Summary collapse
-
#centred(value = true) ⇒ Boolean
(also: #centred!)
Instructs Vedeu to calculate x and y geometry automatically based on the centre character of the terminal, the width and the height.
- #columns(value) ⇒ Object
-
#height(value) ⇒ Fixnum
Specify the number of characters/rows/lines tall the interface will be.
-
#initialize(model, client = nil) ⇒ Vedeu::DSL::Geometry
constructor
Returns an instance of DSL::Geometry.
- #rows(value) ⇒ Object
-
#width(value) ⇒ Fixnum
Specify the number of characters/columns wide the interface will be.
-
#x(value = 1, &block) ⇒ Fixnum
Specify the starting x position (column) of the interface.
-
#xn(value = 1, &block) ⇒ Fixnum
Specify the ending x position (column) of the interface.
-
#y(value = 1, &block) ⇒ Fixnum
Specify the starting y position (row/line) of the interface.
-
#yn(value = 1, &block) ⇒ Fixnum
Specify the ending y position (row/line) of the interface.
Methods included from Use
Methods included from Vedeu::DSL
Constructor Details
#initialize(model, client = nil) ⇒ Vedeu::DSL::Geometry
Returns an instance of DSL::Geometry.
33 34 35 36 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 33 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)
200 201 202 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 200 def client @client end |
#model ⇒ Geometry (readonly, protected)
204 205 206 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 204 def model @model end |
Class Method Details
.geometry(name, &block) ⇒ Vedeu::Geometry
Specify the geometry of an interface or view with a simple DSL.
22 23 24 25 26 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 22 def self.geometry(name, &block) fail InvalidSyntax, 'block not given' unless block_given? Vedeu::Geometry.build({ name: name }, &block).store end |
Instance Method Details
#centred(value = true) ⇒ Boolean Also known as: centred!
Instructs Vedeu to calculate x and y geometry automatically based on the centre character of the terminal, the width and the height.
54 55 56 57 58 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 54 def centred(value = true) boolean = value ? true : false model.centred = boolean end |
#columns(value) ⇒ Object
62 63 64 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 62 def columns(value) Vedeu::Grid.columns(value) end |
#height(value) ⇒ Fixnum
This value will be ignored if by ‘y` and `yn` are set.
Specify the number of characters/rows/lines tall the interface will be.
78 79 80 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 78 def height(value) model.height = value end |
#rows(value) ⇒ Object
83 84 85 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 83 def rows(value) Vedeu::Grid.rows(value) end |
#width(value) ⇒ Fixnum
This value will be ignored if by ‘x` and `xn` are set.
Specify the number of characters/columns wide the interface will be.
100 101 102 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 100 def width(value) model.width = value end |
#x(value = 1, &block) ⇒ Fixnum
Specify the starting x position (column) of the interface.
120 121 122 123 124 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 120 def x(value = 1, &block) return model.x = block if block_given? model.x = value end |
#xn(value = 1, &block) ⇒ Fixnum
This value will override ‘width`.
Specify the ending x position (column) of the interface.
144 145 146 147 148 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 144 def xn(value = 1, &block) return model.xn = block if block_given? model.xn = value end |
#y(value = 1, &block) ⇒ Fixnum
Specify the starting y position (row/line) of the interface.
166 167 168 169 170 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 166 def y(value = 1, &block) return model.y = block if block_given? model.y = value end |
#yn(value = 1, &block) ⇒ Fixnum
This value will override ‘height`.
Specify the ending y position (row/line) of the interface.
190 191 192 193 194 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 190 def yn(value = 1, &block) return model.yn = block if block_given? model.yn = value end |