Module: Rookout::Utils

Defined in:
lib/rookout/utils.rb

Class Method Summary collapse

Class Method Details

.is_number?(string) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/rookout/utils.rb', line 30

def is_number? string
  true if Float(string) rescue false
end

.milliseconds_to_nanoseconds(milliseconds) ⇒ Object



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

def milliseconds_to_nanoseconds milliseconds
  nano = milliseconds * (10**6)
  nano.to_i
end

.quiet_puts(msg) ⇒ Object



23
24
25
26
27
28
# File 'lib/rookout/utils.rb', line 23

def quiet_puts msg
  # rubocop:disable Style/StderrPuts
  return if Config.quiet
  $stderr.puts msg
  # rubocop:enable Style/StderrPuts
end

.time_to_nanoseconds(time_obj) ⇒ Object



17
18
19
20
21
# File 'lib/rookout/utils.rb', line 17

def time_to_nanoseconds time_obj
  secs = time_obj.to_i
  nsecs = time_obj.nsec
  ((10**9) * secs) + nsecs
end

.uuidObject



8
9
10
# File 'lib/rookout/utils.rb', line 8

def uuid
  SecureRandom.uuid.gsub(/-/, "")
end