Class: VK::AGO::Clock

Inherits:
Object
  • Object
show all
Defined in:
lib/valkey/objects.rb

Instance Method Summary collapse

Constructor Details

#initialize(t) ⇒ Clock

Returns a new instance of Clock.



34
35
36
37
38
39
# File 'lib/valkey/objects.rb', line 34

def initialize t
  @t = AGO.now
  @s = @t.to_i - t.to_i
  @t = Time.new(t.to_i).utc
  @d = Duration.new(@s.abs)
end

Instance Method Details

#to_iObject



40
41
42
# File 'lib/valkey/objects.rb', line 40

def to_i
  @s
end

#to_s(*s) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/valkey/objects.rb', line 43

def to_s *s
  if s[0]
    @d.format(s[0])
  else
    @d.format('%w %~w %d %~d %H:%M:%S')
  end
end