class Thumbtack::Types::Date
Handles conversion and validation of Dates to parameters supported by Pinboard
@api private
Constants
- EARLIEST
The earliest allowable date
- LATEST
The latest allowable date
Public Class Methods
deserialize(parameter)
click to toggle source
Convert a parameter from Pinboard to a date
@param [String] parameter
the date with format yyyy-mm-dd
@return [Date]
# File lib/thumbtack/types/date.rb, line 46 def self.deserialize(parameter) ::Date.xmlschema(parameter) end
serialize(value)
click to toggle source
Convert a date to a parameter acceptable to Pinboard
@param [Date] value
the date to convert
@return [String]
the date with format yyyy-mm-dd
# File lib/thumbtack/types/date.rb, line 36 def self.serialize(value) value.xmlschema end
validate(value)
click to toggle source
Validate a date
@param [Date] value
the date to validate
@return [self]
@raise [Types::ValidationError]
if the date is not between 0001-01-01 and 2100-01-01
# File lib/thumbtack/types/date.rb, line 24 def self.validate(value) RangeValidation.validate value, EARLIEST..LATEST self end