Class: JsonTableSchema::Types::Null
- Inherits:
-
Base
- Object
- Base
- JsonTableSchema::Types::Null
show all
- Defined in:
- lib/jsontableschema/types/null.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#cast, #initialize, #set_format, #test
Methods included from Helpers
#convert_to_boolean, #false_values, #get_class_for_type, #true_values, #type_class_lookup
Class Method Details
.supported_constraints ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/jsontableschema/types/null.rb', line 9
def self.supported_constraints
[
'required',
'pattern',
'enum',
]
end
|
Instance Method Details
#cast_default(value) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/jsontableschema/types/null.rb', line 25
def cast_default(value)
if value.is_a?(type)
return value
elsif null_values.include?(value.to_s.downcase)
nil
else
raise JsonTableSchema::InvalidCast.new("#{value} is not a #{name}")
end
end
|
5
6
7
|
# File 'lib/jsontableschema/types/null.rb', line 5
def name
'null'
end
|
#null_values ⇒ Object
21
22
23
|
# File 'lib/jsontableschema/types/null.rb', line 21
def null_values
['null', 'none', 'nil', 'nan', '-', '']
end
|
17
18
19
|
# File 'lib/jsontableschema/types/null.rb', line 17
def type
::NilClass
end
|