Class: Taro::Types::Scalar::ISO8601DateTimeType
- Inherits:
-
Taro::Types::ScalarType
- Object
- BaseType
- Taro::Types::ScalarType
- Taro::Types::Scalar::ISO8601DateTimeType
- Defined in:
- lib/taro/types/scalar/iso8601_datetime_type.rb
Constant Summary
Constants included from Taro::Types::Shared::Pattern
Taro::Types::Shared::Pattern::ADVANCED_RUBY_REGEXP_SYNTAX_REGEXP, Taro::Types::Shared::Pattern::NOT_ESCAPED
Instance Method Summary collapse
Methods included from Taro::Types::Shared::Pattern
included, #pattern, to_es262, validate, validate_no_advanced_syntax, validate_no_flags, validate_not_empty
Instance Method Details
#coerce_input ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/taro/types/scalar/iso8601_datetime_type.rb', line 7 def coerce_input if object.instance_of?(String) && object.match?(pattern) DateTime.iso8601(object) else input_error("must be a ISO8601 formatted string") end end |
#coerce_response ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/taro/types/scalar/iso8601_datetime_type.rb', line 15 def coerce_response case object when Date object.to_datetime.utc.iso8601 when DateTime, Time object.utc.iso8601 else response_error("must be a Time, Date, or DateTime") end end |