Module: Matchi::Number Private
- Defined in:
- lib/matchi/number.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Validation of the numbers given to matchers: deltas and expected values
must be finite and real, so that a NaN, an infinity or a Complex
cannot build a matcher that never, or always, passes.
Class Method Summary collapse
-
.finite_real!(value, role) ⇒ Numeric
private
Value.
-
.finite_real?(value) ⇒ Boolean
private
Whether value is a finite real Numeric.
-
.non_negative!(value, role) ⇒ Numeric
private
Value.
Class Method Details
.finite_real!(value, role) ⇒ Numeric
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 value.
20 21 22 23 24 |
# File 'lib/matchi/number.rb', line 20 def self.finite_real!(value, role) raise ::ArgumentError, "#{role} must be a finite real Numeric (got: #{value.inspect})" unless finite_real?(value) value end |
.finite_real?(value) ⇒ 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.
Returns whether value is a finite real Numeric.
12 13 14 |
# File 'lib/matchi/number.rb', line 12 def self.finite_real?(value) ::Numeric === value && value.real? && value.finite? end |
.non_negative!(value, role) ⇒ Numeric
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 value.
30 31 32 33 34 35 |
# File 'lib/matchi/number.rb', line 30 def self.non_negative!(value, role) finite_real!(value, role) raise ::ArgumentError, "#{role} must be non-negative (got: #{value.inspect})" if value.negative? value end |