Class: Vedeu::Geometries::Area Private
- Inherits:
-
Object
- Object
- Vedeu::Geometries::Area
- Extended by:
- Forwardable
- Defined in:
- lib/vedeu/geometries/area/area.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Define an area from dimensions or points.
Instance Attribute Summary collapse
- #name ⇒ String|Symbol readonly protected private
-
#x ⇒ Fixnum
(also: #left)
readonly
private
Returns the left coordinate (column/character start position) of the interface.
-
#xn ⇒ Fixnum
(also: #right)
readonly
private
Returns the right coordinate (column/ character end position) of the interface.
-
#y ⇒ Fixnum
(also: #top)
readonly
private
Returns the top coordinate (row/line start position) of the interface.
-
#yn ⇒ Fixnum
(also: #bottom)
readonly
private
Returns the bottom coordinate (row/line end position) of the interface.
Class Method Summary collapse
Instance Method Summary collapse
- #border ⇒ Vedeu::Borders::Border private private
-
#bordered_height ⇒ Fixnum
private
Returns the height of the interface determined by whether a top, bottom, both or neither borders are shown.
-
#bordered_width ⇒ Fixnum
private
Returns the width of the interface determined by whether a left, right, both or neither borders are shown.
-
#bx ⇒ Fixnum
private
Return the column position for 1 character right of the left border.
-
#bxn ⇒ Fixnum
private
Return the column position for 1 character left of the right border.
-
#by ⇒ Fixnum
private
Return the row position for 1 character under of the top border.
-
#byn ⇒ Fixnum
private
Return the column position for 1 character above of the bottom border.
-
#centre ⇒ Array<Fixnum>
private
Returns an array containing the centred y and x coordinates of the interface.
-
#centre_x ⇒ Fixnum
private
Returns the centred x coordinate (the horizontal centre character) of the interface.
-
#centre_y ⇒ Fixnum
private
Returns the centred y coordinate (the vertical centre row) of the interface.
-
#east(offset = 1) ⇒ Fixnum
private
Returns the column after right by default.
-
#eql?(other) ⇒ Boolean
(also: #==)
private
An object is equal when its values are the same.
-
#height ⇒ Fixnum
private
Returns the height of the interface.
-
#initialize(name:, y:, yn:, x:, xn:) ⇒ Vedeu::Geometries::Area
constructor
private
Returns a new instance of Vedeu::Area.
-
#north(offset = 1) ⇒ Fixnum
private
Returns the row above the top by default.
-
#south(offset = 1) ⇒ Fixnum
private
Returns the row below the bottom by default.
-
#west(offset = 1) ⇒ Fixnum
private
Returns the column before left by default.
-
#width ⇒ Fixnum
private
Returns the width of the interface.
Constructor Details
#initialize(name:, y:, yn:, x:, xn:) ⇒ Vedeu::Geometries::Area
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Area.
91 92 93 94 95 96 97 |
# File 'lib/vedeu/geometries/area/area.rb', line 91 def initialize(name:, y:, yn:, x:, xn:) @name = name @y = y @yn = yn @x = x @xn = xn end |
Instance Attribute Details
#name ⇒ String|Symbol (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
281 282 283 |
# File 'lib/vedeu/geometries/area/area.rb', line 281 def name @name end |
#x ⇒ Fixnum (readonly) Also known as: left
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the left coordinate (column/character start position) of the interface.
37 38 39 |
# File 'lib/vedeu/geometries/area/area.rb', line 37 def x @x end |
#xn ⇒ Fixnum (readonly) Also known as: right
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the right coordinate (column/ character end position) of the interface.
43 44 45 |
# File 'lib/vedeu/geometries/area/area.rb', line 43 def xn @xn end |
#y ⇒ Fixnum (readonly) Also known as: top
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the top coordinate (row/line start position) of the interface.
25 26 27 |
# File 'lib/vedeu/geometries/area/area.rb', line 25 def y @y end |
#yn ⇒ Fixnum (readonly) Also known as: bottom
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the bottom coordinate (row/line end position) of the interface.
31 32 33 |
# File 'lib/vedeu/geometries/area/area.rb', line 31 def yn @yn end |
Class Method Details
.from_attributes(attributes = {}) ⇒ Vedeu::Geometries::Area
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vedeu/geometries/area/area.rb', line 58 def self.from_attributes(attributes = {}) y_attributes = { alignment: attributes[:vertical_alignment], d: attributes[:y], dn: attributes[:yn], d_dn: attributes[:height], maximised: attributes[:maximised], } x_attributes = { alignment: attributes[:horizontal_alignment], d: attributes[:x], dn: attributes[:xn], d_dn: attributes[:width], maximised: attributes[:maximised], } dy, dyn = Vedeu::Geometries::YDimension.pair(y_attributes) dx, dxn = Vedeu::Geometries::XDimension.pair(x_attributes) new(name: attributes[:name], y: dy, yn: dyn, x: dx, xn: dxn) end |
Instance Method Details
#border ⇒ Vedeu::Borders::Border (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
286 287 288 |
# File 'lib/vedeu/geometries/area/area.rb', line 286 def border @_border ||= Vedeu.borders.by_name(name) end |
#bordered_height ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the height of the interface determined by whether a top, bottom, both or neither borders are shown.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/vedeu/geometries/area/area.rb', line 132 def bordered_height return height unless border && enabled? if top? && bottom? height - 2 elsif top? || bottom? height - 1 else height end end |
#bordered_width ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the width of the interface determined by whether a left, right, both or neither borders are shown.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/vedeu/geometries/area/area.rb', line 113 def bordered_width return width unless border && enabled? if left? && right? width - 2 elsif left? || right? width - 1 else width end end |
#bx ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the column position for 1 character right of the left
border.
151 152 153 |
# File 'lib/vedeu/geometries/area/area.rb', line 151 def bx (enabled? && left?) ? x + 1 : x end |
#bxn ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the column position for 1 character left of the right
border.
159 160 161 |
# File 'lib/vedeu/geometries/area/area.rb', line 159 def bxn (enabled? && right?) ? xn - 1 : xn end |
#by ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the row position for 1 character under of the top
border.
167 168 169 |
# File 'lib/vedeu/geometries/area/area.rb', line 167 def by (enabled? && top?) ? y + 1 : y end |
#byn ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the column position for 1 character above of the bottom
border.
175 176 177 |
# File 'lib/vedeu/geometries/area/area.rb', line 175 def byn (enabled? && bottom?) ? yn - 1 : yn end |
#centre ⇒ Array<Fixnum>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an array containing the centred y and x coordinates of the interface.
183 184 185 |
# File 'lib/vedeu/geometries/area/area.rb', line 183 def centre [centre_y, centre_x] end |
#centre_x ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the centred x coordinate (the horizontal centre character) of the interface.
199 200 201 |
# File 'lib/vedeu/geometries/area/area.rb', line 199 def centre_x (width / 2) + x end |
#centre_y ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the centred y coordinate (the vertical centre row) of the interface.
191 192 193 |
# File 'lib/vedeu/geometries/area/area.rb', line 191 def centre_y (height / 2) + y end |
#east(offset = 1) ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the column after right by default.
243 244 245 |
# File 'lib/vedeu/geometries/area/area.rb', line 243 def east(offset = 1) xn + offset end |
#eql?(other) ⇒ Boolean Also known as: ==
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
An object is equal when its values are the same.
103 104 105 106 |
# File 'lib/vedeu/geometries/area/area.rb', line 103 def eql?(other) self.class == other.class && y == other.y && yn == other.yn && x == other.x && xn == other.xn end |
#height ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the height of the interface.
206 207 208 |
# File 'lib/vedeu/geometries/area/area.rb', line 206 def height (yn - y) + 1 end |
#north(offset = 1) ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the row above the top by default.
228 229 230 |
# File 'lib/vedeu/geometries/area/area.rb', line 228 def north(offset = 1) y - offset end |
#south(offset = 1) ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the row below the bottom by default.
258 259 260 |
# File 'lib/vedeu/geometries/area/area.rb', line 258 def south(offset = 1) yn + offset end |
#west(offset = 1) ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the column before left by default.
273 274 275 |
# File 'lib/vedeu/geometries/area/area.rb', line 273 def west(offset = 1) x - offset end |
#width ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the width of the interface.
213 214 215 |
# File 'lib/vedeu/geometries/area/area.rb', line 213 def width (xn - x) + 1 end |