Class: TableSchema::Types::YearMonth
- Inherits:
-
Base
- Object
- Base
- TableSchema::Types::YearMonth
show all
- Defined in:
- lib/tableschema/types/yearmonth.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#cast, #initialize, #test
Methods included from Helpers
#deep_symbolize_keys, #get_class_for_type, #read_file, #type_class_lookup
Class Method Details
.supported_constraints ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/tableschema/types/yearmonth.rb', line 9
def self.supported_constraints
[
'required',
'unique',
'pattern',
'enum',
'minimum',
'maximum',
]
end
|
Instance Method Details
#cast_default(value) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/tableschema/types/yearmonth.rb', line 24
def cast_default(value)
value = array_to_yearmonth_string(value) if value.class == ::Array
cast = ::Date._strptime(value, '%Y-%m')
unless cast.nil? || cast.include?(:leftover)
array_to_yearmonth(cast.values)
else
raise TableSchema::InvalidYearMonthType.new("#{value} is not a valid yearmonth")
end
end
|
5
6
7
|
# File 'lib/tableschema/types/yearmonth.rb', line 5
def name
'yearmonth'
end
|
20
21
22
|
# File 'lib/tableschema/types/yearmonth.rb', line 20
def type
::Hash
end
|