module WAB::Utils

Constants

TIME_REGEX
UUID_REGEX

Public Class Methods

populated_hash?(obj) click to toggle source

Determine if a given object is not an empty Hash

# File lib/wab/utils.rb, line 17
def populated_hash?(obj)
  obj.is_a?(Hash) && !obj.empty?
end
pre_24_fixnum?(obj) click to toggle source

Detect if `obj` is an instance of `Fixnum` from Ruby older than 2.4.x

# File lib/wab/utils.rb, line 12
def pre_24_fixnum?(obj)
  24 > ruby_series && obj.is_a?(Fixnum)
end
ruby_series() click to toggle source
# File lib/wab/utils.rb, line 7
def ruby_series
  RbConfig::CONFIG.values_at('MAJOR', 'MINOR').join.to_i
end
uuid_format?(str) click to toggle source

Detect if given string matches ISO/IEC UUID format: ā€œ123e4567-e89b-12d3-a456-426655440000ā€

# File lib/wab/utils.rb, line 23
def uuid_format?(str)
  return false unless 36 == str.length
  UUID_REGEX === str
end
wab_time_format?(str) click to toggle source

Detect if given string matches a Time format as encoded by WAB components: ā€œ2017-09-01T12:45:15.123456789Zā€

# File lib/wab/utils.rb, line 30
def wab_time_format?(str)
  return false unless 30 == str.length
  TIME_REGEX === str
end