Class: Vedeu::Geometry::Coordinate Private
- Inherits:
-
Object
- Object
- Vedeu::Geometry::Coordinate
- Defined in:
- lib/vedeu/geometry/coordinate.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.
Crudely corrects out of range values.
Instance Attribute Summary collapse
- #name ⇒ String|Symbol readonly protected private
- #offset ⇒ Fixnum readonly protected private
- #type ⇒ Symbol readonly protected private
Instance Method Summary collapse
-
#bd ⇒ Fixnum
private
private
Return the :bx or :by value from the geometry.
-
#bdn ⇒ Fixnum
private
private
Return the :bxn or :byn value from the geometry.
-
#coordinate_type ⇒ Fixnum
private
private
Ascertain the correct methods to use for determining the coordinates.
-
#d ⇒ Fixnum
private
private
Return the :x or :y value from the geometry.
-
#d_dn ⇒ Fixnum
private
private
Return the :width or :height value from the geometry.
-
#d_position ⇒ Fixnum
(also: #x, #y)
private
Returns the coordinate for a given index.
-
#d_range ⇒ Array
private
private
Returns an array with all coordinates from d to dn.
-
#defaults ⇒ Hash<Symbol => Fixnum|String|Symbol>
private
private
The default values for a new instance of this class.
-
#dn_index ⇒ Fixnum
private
private
Returns the maximum index for an area.
-
#dn_position ⇒ Fixnum
(also: #xn, #yn)
private
Returns the maximum coordinate for an area.
-
#geometry ⇒ Object
private
private
Returns the geometry for the interface.
-
#initialize(attributes = {}) ⇒ Vedeu::Geometry::Coordinate
constructor
private
Return a new instance of Vedeu::Geometry::Coordinate.
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Geometry::Coordinate
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 a new instance of Vedeu::Geometry::Coordinate.
18 19 20 21 22 |
# File 'lib/vedeu/geometry/coordinate.rb', line 18 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end 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.
73 74 75 |
# File 'lib/vedeu/geometry/coordinate.rb', line 73 def name @name end |
#offset ⇒ Fixnum (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.
77 78 79 |
# File 'lib/vedeu/geometry/coordinate.rb', line 77 def offset @offset end |
#type ⇒ 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.
81 82 83 |
# File 'lib/vedeu/geometry/coordinate.rb', line 81 def type @type end |
Instance Method Details
#bd ⇒ Fixnum (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.
Return the :bx or :by value from the geometry.
102 103 104 |
# File 'lib/vedeu/geometry/coordinate.rb', line 102 def bd geometry.send(coordinate_type[1]) end |
#bdn ⇒ Fixnum (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.
Return the :bxn or :byn value from the geometry.
109 110 111 |
# File 'lib/vedeu/geometry/coordinate.rb', line 109 def bdn geometry.send(coordinate_type[2]) end |
#coordinate_type ⇒ Fixnum (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.
Ascertain the correct methods to use for determining the coordinates.
126 127 128 129 130 131 132 133 134 |
# File 'lib/vedeu/geometry/coordinate.rb', line 126 def coordinate_type @_type ||= case type when :x then [:x, :bx, :bxn, :bordered_width] when :y then [:y, :by, :byn, :bordered_height] else fail Vedeu::Error::InvalidSyntax, 'Coordinate type not given, cannot continue.'.freeze end end |
#d ⇒ Fixnum (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.
Return the :x or :y value from the geometry.
95 96 97 |
# File 'lib/vedeu/geometry/coordinate.rb', line 95 def d geometry.send(coordinate_type[0]) end |
#d_dn ⇒ Fixnum (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.
Return the :width or :height value from the geometry.
116 117 118 |
# File 'lib/vedeu/geometry/coordinate.rb', line 116 def d_dn geometry.send(coordinate_type[3]) end |
#d_position ⇒ Fixnum Also known as: x, y
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 coordinate for a given index.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/vedeu/geometry/coordinate.rb', line 50 def d_position pos = if offset <= 0 d elsif offset > dn_index dn_position else d_range[offset] end pos = pos < bd ? bd : pos pos = pos > bdn ? bdn : pos pos end |
#d_range ⇒ Array (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.
Returns an array with all coordinates from d to dn.
158 159 160 |
# File 'lib/vedeu/geometry/coordinate.rb', line 158 def d_range (d...dn_position).to_a end |
#defaults ⇒ Hash<Symbol => Fixnum|String|Symbol> (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.
The default values for a new instance of this class.
165 166 167 168 169 170 171 |
# File 'lib/vedeu/geometry/coordinate.rb', line 165 def defaults { name: '', offset: nil, type: :x, } end |
#dn_index ⇒ Fixnum (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.
Returns the maximum index for an area.
143 144 145 146 147 |
# File 'lib/vedeu/geometry/coordinate.rb', line 143 def dn_index return 0 if d_dn < 1 d_dn - 1 end |
#dn_position ⇒ Fixnum Also known as: xn, yn
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 maximum coordinate for an area.
32 33 34 35 36 |
# File 'lib/vedeu/geometry/coordinate.rb', line 32 def dn_position return 0 if d_dn <= 0 d + d_dn end |
#geometry ⇒ Object (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.
Returns the geometry for the interface.
88 89 90 |
# File 'lib/vedeu/geometry/coordinate.rb', line 88 def geometry @geometry ||= Vedeu.geometries.by_name(name) end |