Class: Dry::Logger::Clock Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/logger/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.

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unit: :nanosecond) ⇒ Clock

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.

Returns a new instance of Clock.

Since:

  • 1.0.0



14
15
16
# File 'lib/dry/logger/clock.rb', line 14

def initialize(unit: :nanosecond)
  @unit = unit
end

Instance Attribute Details

#unitObject (readonly)

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.

Since:

  • 1.0.0



10
11
12
# File 'lib/dry/logger/clock.rb', line 10

def unit
  @unit
end

Instance Method Details

#measureObject

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.

Since:

  • 1.0.0



32
33
34
35
36
# File 'lib/dry/logger/clock.rb', line 32

def measure
  start = current
  result = yield
  [result, current - start]
end

#nowObject

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.

Since:

  • 1.0.0



20
21
22
# File 'lib/dry/logger/clock.rb', line 20

def now
  Time.now
end

#now_utcObject

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.

Since:

  • 1.0.0



26
27
28
# File 'lib/dry/logger/clock.rb', line 26

def now_utc
  now.getutc
end