Method: Path#siblings
- Defined in:
- lib/path/dir.rb
#siblings(with_directory = true) ⇒ Object
Equivalent of parent.children - [self]. Returns the siblings, the files in the same directory as the current path. Returns only the root if path is the root. The sibling paths are always sorted to ensure a deterministic order.
165 166 167 168 169 170 171 |
# File 'lib/path/dir.rb', line 165 def siblings(with_directory = true) if root? [self] else parent.children(with_directory) - [(with_directory ? self : basename)] end end |