Sha256: 8930e24348c96adc0441c045ff88eaba1bf30ae556c5a8f9164f9d4aee65c3c6
Contents?: true
Size: 632 Bytes
Versions: 6
Compression:
Stored size: 632 Bytes
Contents
module Rasti module Types class Time include Castable attr_reader :format def self.[](format) new format end def to_s "#{self.class}['#{format}']" end alias_method :inspect, :to_s private def initialize(format) @format = format end def valid?(value) value.is_a?(::String) || value.respond_to?(:to_time) end def transform(value) value.is_a?(::String) ? string_to_time(value) : value.to_time end def string_to_time(value) ::Time.strptime(value, format) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems