Class: JSON::Schema::Number

Inherits:
Leaf
  • Object
show all
Defined in:
lib/json/schema/number.rb

Instance Method Summary collapse

Methods inherited from Leaf

#default, #description, #enum, #initialize, #required, #required?, #to_json

Constructor Details

This class inherits a constructor from JSON::Schema::Leaf

Instance Method Details

#max(i) ⇒ Object



9
10
11
# File 'lib/json/schema/number.rb', line 9

def max(i)
  tap { @maximum = i }
end

#min(i) ⇒ Object



5
6
7
# File 'lib/json/schema/number.rb', line 5

def min(i)
  tap { @minimum = i }
end

#to_hObject



13
14
15
16
17
18
19
# File 'lib/json/schema/number.rb', line 13

def to_h
  super.merge!({
    type: "number",
    minimum: @minimum,
    maximum: @maximum
  }).compact
end