Class: Vedeu::Cursors::Coordinate Private
- Inherits:
-
Object
- Object
- Vedeu::Cursors::Coordinate
- Extended by:
- Forwardable
- 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
- #geometry ⇒ Vedeu::Geometries::Geometry readonly protected private
- #offset ⇒ Fixnum readonly protected private
- #type ⇒ Symbol readonly protected private
Instance Method Summary collapse
- #coordinate ⇒ Vedeu::XCoordinate|Vedeu::YCoordinate private private
-
#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 => void>
private
private
The default options/attributes 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.
-
#initialize(attributes = {}) ⇒ Vedeu::Cursors::Coordinate
constructor
private
Return a new instance of Vedeu::Cursors::Coordinate.
-
#position ⇒ Fixnum
private
private
Return the position respective of the offset.
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.
28 29 30 31 32 |
# File 'lib/vedeu/cursors/coordinate.rb', line 28 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#geometry ⇒ Vedeu::Geometries::Geometry (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.
70 71 72 |
# File 'lib/vedeu/cursors/coordinate.rb', line 70 def geometry @geometry 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.
74 75 76 |
# File 'lib/vedeu/cursors/coordinate.rb', line 74 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.
78 79 80 |
# File 'lib/vedeu/cursors/coordinate.rb', line 78 def type @type end |
Instance Method Details
#coordinate ⇒ Vedeu::XCoordinate|Vedeu::YCoordinate (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.
84 85 86 87 88 89 90 91 92 |
# File 'lib/vedeu/cursors/coordinate.rb', line 84 def coordinate @_coordinate ||= case type when :x then Vedeu::XCoordinate.new(geometry) when :y then Vedeu::YCoordinate.new(geometry) else raise Vedeu::Error::InvalidSyntax, 'Coordinate type not given, cannot continue.' end 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.
60 61 62 |
# File 'lib/vedeu/cursors/coordinate.rb', line 60 def d_position Vedeu::Point.coerce(value: position, 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.
116 117 118 |
# File 'lib/vedeu/cursors/coordinate.rb', line 116 def d_range (d...dn_position).to_a end |
#defaults ⇒ Hash<Symbol => void> (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 options/attributes for a new instance of this class.
121 122 123 124 125 126 127 |
# File 'lib/vedeu/cursors/coordinate.rb', line 121 def defaults { geometry: nil, 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.
101 102 103 104 105 |
# File 'lib/vedeu/cursors/coordinate.rb', line 101 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.
42 43 44 45 46 |
# File 'lib/vedeu/cursors/coordinate.rb', line 42 def dn_position return 0 if d_dn <= 0 d + d_dn end |
#position ⇒ 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 position respective of the offset.
132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/vedeu/cursors/coordinate.rb', line 132 def position if offset <= 0 d elsif offset > dn_index dn_position else d_range[offset] end end |