Sha256: 1efb71a9458aad66600252f783a43865fd415406b78454f649c60f1153531365

Contents?: true

Size: 602 Bytes

Versions: 7

Compression:

Stored size: 602 Bytes

Contents

module Kuby
  module Docker
    class TimestampTag
      RE = /20[\d]{2}(?:0[1-9]|11|12)(?:0[1-9]|1[1-9]|2[1-9]|3[01])/.freeze
      FORMAT = '%Y%m%d%H%M%S'.freeze

      def self.try_parse(str)
        if str =~ RE
          new(Time.strptime(str, FORMAT))
        end
      end

      attr_reader :time

      def initialize(time)
        @time = time
      end

      def to_s
        time.strftime(FORMAT)
      end

      def <=>(other)
        time <=> other.time
      end

      def hash
        time.hash
      end

      def eql?(other)
        time == other.time
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kuby-core-0.6.1 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.6.0 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.5.0 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.4.0 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.3.0 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.2.0 lib/kuby/docker/timestamp_tag.rb
kuby-core-0.1.0 lib/kuby/docker/timestamp_tag.rb