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



45
46
47
48
49
50
51
52
53
54
# File 'lib/legion/api/identity_audit.rb', line 45

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