Class: Kuby::Docker::TimestampTag

Inherits:
Object
  • Object
show all
Defined in:
lib/kuby/docker/timestamp_tag.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time) ⇒ TimestampTag

Returns a new instance of TimestampTag.



15
16
17
# File 'lib/kuby/docker/timestamp_tag.rb', line 15

def initialize(time)
  @time = time
end

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time.



13
14
15
# File 'lib/kuby/docker/timestamp_tag.rb', line 13

def time
  @time
end

Class Method Details

.try_parse(str) ⇒ Object



7
8
9
10
11
# File 'lib/kuby/docker/timestamp_tag.rb', line 7

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

Instance Method Details

#<=>(other) ⇒ Object



23
24
25
# File 'lib/kuby/docker/timestamp_tag.rb', line 23

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/kuby/docker/timestamp_tag.rb', line 31

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

#hashObject



27
28
29
# File 'lib/kuby/docker/timestamp_tag.rb', line 27

def hash
  time.hash
end

#to_sObject



19
20
21
# File 'lib/kuby/docker/timestamp_tag.rb', line 19

def to_s
  time.strftime(FORMAT)
end