Module: Legion::API::Routes::IdentityAudit::IdentityAuditHelpers

Defined in:
lib/legion/api/identity_audit.rb

Instance Method Summary collapse

Instance Method Details

#parse_since_duration(value) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/legion/api/identity_audit.rb', line 65

def parse_since_duration(value)
  return nil unless value.is_a?(String)

  case value
  when /\A(\d+)h\z/ then Regexp.last_match(1).to_i * 3600
  when /\A(\d+)m\z/ then Regexp.last_match(1).to_i * 60
  when /\A(\d+)s\z/ then Regexp.last_match(1).to_i
  when /\A(\d+)d\z/ then Regexp.last_match(1).to_i * 86_400
  end
end