Class: Vedeu::Point Private
- Inherits:
-
Object
- Object
- Vedeu::Point
- Defined in:
- lib/vedeu/support/point.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.
A ‘Vedeu::Point` represents part of a coordinate within the 2D space of a terminal. This class is specifically used to coerce a coordinate to be within boundaries. The `min` and `max` arguments are used to define this boundary.
Class Method Summary collapse
- .coerce(value: nil, min: 1, max: nil) ⇒ Vedeu::Point private
- .valid?(value: nil, min: 1, max: nil) ⇒ Boolean, Vedeu::Point private
Instance Method Summary collapse
- #coerce ⇒ Vedeu::Point private
- #initialize(value: nil, min: 1, max: nil) ⇒ Vedeu::Point constructor private
- #max ⇒ Fixnum private private
- #min ⇒ Fixnum private private
- #valid? ⇒ Boolean private
- #value ⇒ Fixnum private
Constructor Details
#initialize(value: nil, min: 1, max: nil) ⇒ Vedeu::Point
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.
29 30 31 32 33 |
# File 'lib/vedeu/support/point.rb', line 29 def initialize(value: nil, min: 1, max: nil) @min = min @max = max @value = value end |
Class Method Details
.coerce(value: nil, min: 1, max: nil) ⇒ Vedeu::Point
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.
15 16 17 |
# File 'lib/vedeu/support/point.rb', line 15 def self.coerce(value: nil, min: 1, max: nil) new(value: value, min: min, max: max).coerce end |
.valid?(value: nil, min: 1, max: nil) ⇒ Boolean, Vedeu::Point
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.
21 22 23 |
# File 'lib/vedeu/support/point.rb', line 21 def self.valid?(value: nil, min: 1, max: nil) new(value: value, min: min, max: max).valid? end |
Instance Method Details
#coerce ⇒ Vedeu::Point
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.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vedeu/support/point.rb', line 37 def coerce fail Vedeu::Error::InvalidSyntax, "Expecting 'min' to be less than 'max'." if min > max if value < min Vedeu::Point.coerce(value: min, min: min, max: max) elsif value > max Vedeu::Point.coerce(value: max, min: min, max: max) else self end end |
#max ⇒ 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.
75 76 77 78 79 |
# File 'lib/vedeu/support/point.rb', line 75 def max return @max if @max.is_a?(Fixnum) fail Vedeu::Error::InvalidSyntax, "Expecting 'max' to be a Fixnum." end |
#min ⇒ 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.
67 68 69 70 71 |
# File 'lib/vedeu/support/point.rb', line 67 def min return @min if @min.is_a?(Fixnum) fail Vedeu::Error::InvalidSyntax, "Expecting 'min' to be a Fixnum." end |
#valid? ⇒ Boolean
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.
54 55 56 |
# File 'lib/vedeu/support/point.rb', line 54 def valid? @value.is_a?(Fixnum) && @value >= min && @value <= max end |
#value ⇒ 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.
59 60 61 |
# File 'lib/vedeu/support/point.rb', line 59 def value @value ||= min end |