Write a function that provides change directory (cd) function for an abstract file system.
- Root path is '/'.
- Path separator is '/'.
- Parent directory is addressable as '..'.
- Directory names consist only of English alphabet letters (A-Z and a-z).
- The function should support both relative and absolute paths.
- The function will not be passed any invalid paths.
- Do not use built-in path-related functions.
path = Path.new('/a/b/c/d') path.cd('../x') puts path.current_path
should display '/a/b/c/x'.
- Example case: Wrong answer
- Selecting child directories: Wrong answer
- Selecting parent directories: Wrong answer
- Selecting complex paths: Wrong answer