Module: Otto::Utils
Overview
Utility methods for common operations and helpers
Instance Method Summary collapse
-
#now ⇒ Time
Current time in UTC.
-
#now_in_μs ⇒ Integer
(also: #now_in_microseconds)
Returns the current time in microseconds.
-
#yes?(value) ⇒ Boolean
Determine if a value represents a “yes” or true value.
Instance Method Details
#now ⇒ Time
Returns Current time in UTC.
11 12 13 |
# File 'lib/otto/utils.rb', line 11 def now Time.now.utc end |
#now_in_μs ⇒ Integer 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
21 22 23 |
# File 'lib/otto/utils.rb', line 21 def now_in_μs Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond) end |
#yes?(value) ⇒ Boolean
Determine if a value represents a “yes” or true value
Examples: yes?(‘true’) # => true yes?(‘yes’) # => true yes?(‘1’) # => true
35 36 37 |
# File 'lib/otto/utils.rb', line 35 def yes?(value) !value.to_s.empty? && %w[true yes 1].include?(value.to_s.downcase) end |