I keep stumbling on Ruby globals, there's one that remembers which files have been required.
If you've ever required a file on irb, you can see that require returns a boolean. If true is returned, the file will be parsed and loaded, otherwise the file has already been loaded and it won't be loaded again.
$LOADED_FEATURES is a global array, each time a file is required, this array is queried – if the filename is present in the array, the file won't be loaded.