Class: JsonStructure::Number
Direct Known Subclasses
Instance Method Summary collapse
- #===(value) ⇒ Object
-
#initialize(min: nil, max: nil) ⇒ Number
constructor
A new instance of Number.
Methods inherited from Type
Constructor Details
#initialize(min: nil, max: nil) ⇒ Number
Returns a new instance of Number.
3 4 5 6 |
# File 'lib/json_structure/number.rb', line 3 def initialize(min: nil, max: nil) @min = min @max = max end |
Instance Method Details
#===(value) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/json_structure/number.rb', line 8 def ===(value) return false unless value.is_a?(::Integer) || value.is_a?(::Float) return false if @min && value < @min return false if @max && value > @max true end |