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 private
- #model ⇒ Geometry readonly private
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.
-
#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.
-
#width(value) ⇒ Fixnum
Specify the number of characters/columns wide the interface will be.
-
#x(value = 0, &block) ⇒ Fixnum
Specify the starting x position (column) of the interface.
-
#y(value = 0, &block) ⇒ Fixnum
Specify the starting 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.
37 38 39 40 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 37 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, private)
140 141 142 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 140 def client @client end |
#model ⇒ Geometry (readonly, private)
143 144 145 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 143 def model @model end |
Class Method Details
.geometry(name, &block) ⇒ Vedeu::Geometry
Specify the geometry of an interface or view with a simple DSL.
26 27 28 29 30 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 26 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.
58 59 60 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 58 def centred(value = true) model.centred = !!value end |
#height(value) ⇒ Fixnum
Specify the number of characters/rows/lines tall the interface will be.
73 74 75 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 73 def height(value) model.height = value end |
#width(value) ⇒ Fixnum
Specify the number of characters/columns wide the interface will be.
87 88 89 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 87 def width(value) model.width = value end |
#x(value = 0, &block) ⇒ Fixnum
Specify the starting x position (column) of the interface.
108 109 110 111 112 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 108 def x(value = 0, &block) return model.x = block if block_given? model.x = value end |
#y(value = 0, &block) ⇒ Fixnum
Specify the starting y position (row/line) of the interface.
131 132 133 134 135 |
# File 'lib/vedeu/dsl/components/geometry.rb', line 131 def y(value = 0, &block) return model.y = block if block_given? model.y = value end |