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

Version Path
kuby-core-0.11.16 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.15 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.14 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.13 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.12 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.11 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.10 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.9 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.8 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.7 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.6 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.4 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.3 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.2 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.1 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.11.0 lib/kuby/docker/timestamp_tag.rb