class Taipu::Number
The type number.
Public Class Methods
new(min: nil, max: nil)
click to toggle source
# File lib/taipu/number.rb, line 7 def initialize(min: nil, max: nil) fail 'MinIsGreaterThanMaxError' if !min.nil? && !max.nil? && min > max @min = min @max = max end
Public Instance Methods
constraints()
click to toggle source
# File lib/taipu/number.rb, line 22 def constraints { min: @min, max: @max } end
valid?(value)
click to toggle source
# File lib/taipu/number.rb, line 14 def valid?(value) return false unless value.is_a?(::Numeric) return false if !@min.nil? && value < @min return false if !@max.nil? && value > @max true end