Class: Skylight::Core::Util::Clock Private
- Inherits:
-
Object
- Object
- Skylight::Core::Util::Clock
- 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
- .default ⇒ Object private
Class Method Summary collapse
- .absolute_secs ⇒ Object private
- .nanos ⇒ Object private
- .secs ⇒ Object private
- .use_native! ⇒ Object private
Instance Method Summary collapse
-
#absolute_secs ⇒ Object
private
TODO: rename to secs.
-
#nanos ⇒ Object
private
TODO: remove.
-
#secs ⇒ Object
private
TODO: remove.
-
#tick ⇒ Object
private
rubocop:disable Lint/DuplicateMethods.
Class Attribute Details
.default ⇒ 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.
48 49 50 |
# File 'lib/skylight/core/util/clock.rb', line 48 def default @default ||= Clock.new end |
Class Method Details
.absolute_secs ⇒ 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.
36 37 38 |
# File 'lib/skylight/core/util/clock.rb', line 36 def absolute_secs default.absolute_secs end |
.nanos ⇒ 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.
40 41 42 |
# File 'lib/skylight/core/util/clock.rb', line 40 def nanos default.nanos end |
.secs ⇒ 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.
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_secs ⇒ 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.
TODO: rename to secs
21 22 23 |
# File 'lib/skylight/core/util/clock.rb', line 21 def absolute_secs Time.now.to_i end |
#nanos ⇒ 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.
TODO: remove
26 27 28 |
# File 'lib/skylight/core/util/clock.rb', line 26 def nanos tick end |
#secs ⇒ 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.
TODO: remove
31 32 33 |
# File 'lib/skylight/core/util/clock.rb', line 31 def secs nanos / 1_000_000_000 end |
#tick ⇒ 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.
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 |