Class: Vedeu::Cursors::Coordinate Private
- Inherits:
-
Object
- Object
- Vedeu::Cursors::Coordinate
- Defined in:
- lib/vedeu/cursors/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::Cursors::Coordinate
constructor
private
Return a new instance of Vedeu::Cursors::Coordinate.
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Cursors::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::Cursors::Coordinate.
20 21 22 23 24 |
# File 'lib/vedeu/cursors/coordinate.rb', line 20 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/cursors/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/cursors/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/cursors/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/cursors/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/cursors/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.
125 126 127 128 129 130 131 132 133 |
# File 'lib/vedeu/cursors/coordinate.rb', line 125 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.' 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/cursors/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/cursors/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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/vedeu/cursors/coordinate.rb', line 52 def d_position pos = if offset <= 0 d elsif offset > dn_index dn_position else d_range[offset] end Vedeu::Point.coerce(value: pos, min: bd, max: bdn).value 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.
157 158 159 |
# File 'lib/vedeu/cursors/coordinate.rb', line 157 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.
164 165 166 167 168 169 170 |
# File 'lib/vedeu/cursors/coordinate.rb', line 164 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.
142 143 144 145 146 |
# File 'lib/vedeu/cursors/coordinate.rb', line 142 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.
34 35 36 37 38 |
# File 'lib/vedeu/cursors/coordinate.rb', line 34 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/cursors/coordinate.rb', line 88 def geometry @geometry ||= Vedeu.geometries.by_name(name) end |