Class: Vedeu::Geometry::Area Private
- Inherits:
-
Object
- Object
- Vedeu::Geometry::Area
- Defined in:
- lib/vedeu/geometry/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
-
#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
-
#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(y:, yn:, x:, xn:) ⇒ Vedeu::Geometry::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(y:, yn:, x:, xn:) ⇒ Vedeu::Geometry::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.
76 77 78 79 80 81 |
# File 'lib/vedeu/geometry/area.rb', line 76 def initialize(y:, yn:, x:, xn:) @y = y @yn = yn @x = x @xn = xn end |
Instance Attribute Details
#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.
26 27 28 |
# File 'lib/vedeu/geometry/area.rb', line 26 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.
32 33 34 |
# File 'lib/vedeu/geometry/area.rb', line 32 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.
14 15 16 |
# File 'lib/vedeu/geometry/area.rb', line 14 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.
20 21 22 |
# File 'lib/vedeu/geometry/area.rb', line 20 def yn @yn end |
Class Method Details
.from_attributes(attributes = {}) ⇒ Vedeu::Geometry::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.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/vedeu/geometry/area.rb', line 48 def self.from_attributes(attributes = {}) y_attributes = { d: attributes[:y], dn: attributes[:yn], d_dn: attributes[:y_yn], maximised: attributes[:maximised], alignment: attributes[:vertical_alignment], } x_attributes = { d: attributes[:x], dn: attributes[:xn], d_dn: attributes[:x_xn], maximised: attributes[:maximised], alignment: attributes[:horizontal_alignment], } y_yn = Vedeu::Geometry::YDimension.pair(y_attributes) x_xn = Vedeu::Geometry::XDimension.pair(x_attributes) new(y: y_yn[0], yn: y_yn[-1], x: x_xn[0], xn: x_xn[-1]) end |
Instance Method Details
#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.
97 98 99 |
# File 'lib/vedeu/geometry/area.rb', line 97 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.
113 114 115 |
# File 'lib/vedeu/geometry/area.rb', line 113 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.
105 106 107 |
# File 'lib/vedeu/geometry/area.rb', line 105 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.
157 158 159 |
# File 'lib/vedeu/geometry/area.rb', line 157 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.
87 88 89 90 |
# File 'lib/vedeu/geometry/area.rb', line 87 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.
120 121 122 |
# File 'lib/vedeu/geometry/area.rb', line 120 def height (y..yn).size 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.
142 143 144 |
# File 'lib/vedeu/geometry/area.rb', line 142 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.
172 173 174 |
# File 'lib/vedeu/geometry/area.rb', line 172 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.
187 188 189 |
# File 'lib/vedeu/geometry/area.rb', line 187 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.
127 128 129 |
# File 'lib/vedeu/geometry/area.rb', line 127 def width (x..xn).size end |