Sha256: a6caaf964cba4d725bb36254df673875dd7e21e5e4912485c1eafe21c53ac326
Contents?: true
Size: 1.09 KB
Versions: 16
Compression:
Stored size: 1.09 KB
Contents
# typed: strict require 'time' module Kuby module Docker class TimestampTag extend T::Sig FORMAT = T.let('%Y%m%d%H%M%S'.freeze, String) sig { params(str: String).returns(T.nilable(TimestampTag)) } def self.try_parse(str) time = begin Time.strptime(str, FORMAT) rescue ArgumentError return nil end new(time) end sig { returns(Time) } attr_reader :time sig { params(time: Time).void } def initialize(time) @time = T.let(time, Time) end sig { returns(String) } def to_s time.strftime(FORMAT) end sig { params(other: TimestampTag).returns(T.nilable(Integer)) } def <=>(other) time <=> other.time end sig { params(other: TimestampTag).returns(T::Boolean) } def ==(other) time == other.time end sig { returns(Integer) } def hash time.hash end sig { params(other: TimestampTag).returns(T::Boolean) } def eql?(other) time == other.time end end end end
Version data entries
16 entries across 16 versions & 1 rubygems