Module: Rhales::Utils

Included in:
Rhales, LoggingHelpers
Defined in:
lib/rhales/utils.rb,
lib/rhales/utils/logging_helpers.rb

Defined Under Namespace

Modules: LoggingHelpers

Instance Method Summary collapse

Instance Method Details

#nowTime

Returns Current time in UTC.

Returns:

  • (Time)

    Current time in UTC



12
13
14
# File 'lib/rhales/utils.rb', line 12

def now
  Time.now.utc
end

#now_in_μsInteger Also known as: now_in_microseconds

Returns the current time in microseconds. This is used to measure the duration of Database commands.

Alias: now_in_microseconds

Returns:

  • (Integer)

    The current time in microseconds.



22
23
24
# File 'lib/rhales/utils.rb', line 22

def now_in_μs
  Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
end

#pretty_path(filepath) ⇒ String?

Returns The expanded absolute path, or nil if input is.

Parameters:

  • filepath (String, nil)

    The file path to prettify

Returns:

  • (String, nil)

    The expanded absolute path, or nil if input is



29
30
31
32
33
# File 'lib/rhales/utils.rb', line 29

def pretty_path(filepath)
  return nil if filepath.nil?

  Pathname.new(filepath).expand_path.to_s
end