Class: JSON::Schema::Integer
Overview
The JSON::Schema::Integer class represents a whole number value in a JSON schema. It is a subclass of JSON::Schema::Leaf and provides methods that can act as constraints.
Instance Method Summary collapse
-
#min(i) ⇒ JSON::Schema::Number
Constrain the number to a minimum value.
-
#max(i) ⇒ JSON::Schema::Number
Constrain the number to a maximum value.
-
#multiple_of(i) ⇒ JSON::Schema::Number
Constrain the number to a multiple of a given value.
-
#to_h ⇒ Object
Methods inherited from Leaf
#const, #default, #description, #enum, #initialize, #required, #required?, #to_json
Constructor Details
This class inherits a constructor from JSON::Schema::Leaf
Instance Method Details
#min(i) ⇒ JSON::Schema::Number
Constrain the number to a minimum value
14 15 16 |
# File 'lib/json/schema/integer.rb', line 14 def min(i) tap { @minimum = i } end |
#max(i) ⇒ JSON::Schema::Number
Constrain the number to a maximum value
22 23 24 |
# File 'lib/json/schema/integer.rb', line 22 def max(i) tap { @maximum = i } end |
#multiple_of(i) ⇒ JSON::Schema::Number
Constrain the number to a multiple of a given value
30 31 32 |
# File 'lib/json/schema/integer.rb', line 30 def multiple_of(i) tap { @multiple_of = i } end |
#to_h ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/json/schema/integer.rb', line 34 def to_h super.merge!({ type: "integer", minimum: @minimum, maximum: @maximum, multipleOf: @multiple_of }).compact end |