fn string_to_path(_: &mut VM, mut string: Value, msg: &str) -> Result<PathBuf, RubyError> {
    let file = string.expect_string(msg)?;
    let mut path = PathBuf::new();
    for p in PathBuf::from(file).iter() {
        if p == ".." && path.file_name().is_some() {
            path.pop();
        } else {
            path.push(p);
        };
    }
    Ok(path)
}
Convert Ruby String value`string` to PathBuf.
ruruby/src/builtin/file.rs