Yea here’s how you can do that, you can call split
on the string. Here’s a little program I made to demonstrate this. IDK if you want domain1
in the scratch path or domain1.local
so I’ve given both here.
require 'etc'
# login should be Etc.getlogin
login = 'johrstrom@domain1.local'
basename, domain = login.split('@')
puts "/scratch/#{domain}/#{basename}"
# you want domain1 not 'domain1.local'
no_local_domain = domain.split('.').first
puts "/scratch/#{no_local_domain}/#{basename}"