class JsonTableSchema::Types::Time
Public Class Methods
supported_constraints()
click to toggle source
# File lib/jsontableschema/types/time.rb, line 9 def self.supported_constraints [ 'required', 'pattern', 'enum', 'minimum', 'maximum', ] end
Public Instance Methods
cast_any(value)
click to toggle source
# File lib/jsontableschema/types/time.rb, line 32 def cast_any(value) return value if value.is_a?(type) begin return ::Tod::TimeOfDay.parse(value) rescue ArgumentError raise JsonTableSchema::InvalidTimeType.new("#{value} is not a valid time") end end
cast_default(value)
click to toggle source
# File lib/jsontableschema/types/time.rb, line 27 def cast_default(value) @format_string = iso8601 cast_fmt(value) end
cast_fmt(value)
click to toggle source
# File lib/jsontableschema/types/time.rb, line 42 def cast_fmt(value) return value if value.is_a?(type) begin time = ::Time.strptime(value, @format_string) return time.to_time_of_day rescue ArgumentError, TypeError raise JsonTableSchema::InvalidTimeType.new("#{value} is not a valid time") end end
iso8601()
click to toggle source
# File lib/jsontableschema/types/time.rb, line 23 def iso8601 '%H:%M:%S' end
name()
click to toggle source
# File lib/jsontableschema/types/time.rb, line 5 def name 'time' end
type()
click to toggle source
# File lib/jsontableschema/types/time.rb, line 19 def type ::Tod::TimeOfDay end