Module: Qyu::Utils

Defined in:
lib/qyu/utils.rb

Overview

Qyu::Utils

Class Method Summary collapse

Class Method Details

.seconds_after_time(seconds, start_time = Time.now) ⇒ Time

Calculates end time after a number of seconds

Parameters:

  • seconds (Integer)

    number of seconds after time

  • start_time (Time) (defaults to: Time.now)

    time to start from

Returns:

  • (Time)

    end time



11
12
13
# File 'lib/qyu/utils.rb', line 11

def self.seconds_after_time(seconds, start_time = Time.now)
  start_time + seconds
end

.stringify_hash_keys(object) ⇒ String

Convert all hash keys to strings

Parameters:

  • object (Hash)

    Hash to stringify its keys

Returns:

  • (String)

    Hash with string keys



26
27
28
# File 'lib/qyu/utils.rb', line 26

def self.stringify_hash_keys(object)
  object.map { |k, v| [k.to_s, v] }.to_h
end

.uuidString

Generates a unique UUID

Returns:

  • (String)

    UUID



18
19
20
# File 'lib/qyu/utils.rb', line 18

def self.uuid
  SecureRandom.uuid
end