Class: Skylight::Core::Util::Clock Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/core/util/clock.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A more precise clock

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.defaultObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
# File 'lib/skylight/core/util/clock.rb', line 48

def default
  @default ||= Clock.new
end

Class Method Details

.absolute_secsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/skylight/core/util/clock.rb', line 36

def absolute_secs
  default.absolute_secs
end

.nanosObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/skylight/core/util/clock.rb', line 40

def nanos
  default.nanos
end

.secsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
# File 'lib/skylight/core/util/clock.rb', line 44

def secs
  default.secs
end

.use_native!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
8
9
10
11
# File 'lib/skylight/core/util/clock.rb', line 5

def self.use_native!
  class_eval do
    def tick
      native_hrtime
    end
  end
end

Instance Method Details

#absolute_secsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: rename to secs



21
22
23
# File 'lib/skylight/core/util/clock.rb', line 21

def absolute_secs
  Time.now.to_i
end

#nanosObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: remove



26
27
28
# File 'lib/skylight/core/util/clock.rb', line 26

def nanos
  tick
end

#secsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: remove



31
32
33
# File 'lib/skylight/core/util/clock.rb', line 31

def secs
  nanos / 1_000_000_000
end

#tickObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Lint/DuplicateMethods



14
15
16
17
# File 'lib/skylight/core/util/clock.rb', line 14

def tick
  now = Time.now
  now.to_i * 1_000_000_000 + now.usec * 1_000
end