Module: Vector2d::Coordinates
Overview
Coordinate validation, shared by the class methods that parse input and by the constructor.
Class Method Summary collapse
-
.coordinate(value) ⇒ Integer, ...
Returns the value if it is a valid coordinate, raises ArgumentError otherwise.
Class Method Details
.coordinate(value) ⇒ Integer, ...
Returns the value if it is a valid coordinate, raises ArgumentError otherwise. Coordinates are real numbers, so Complex is rejected along with everything outside Numeric.
15 16 17 18 19 20 |
# File 'lib/vector2d/coordinates.rb', line 15 def coordinate(value) return value if value.is_a?(Float) || value.is_a?(Integer) raise ArgumentError, "not a valid coordinate: #{value.inspect}" unless value.is_a?(Numeric) && value.real? value end |