liveBook · Manning

Regular file

As explained in The Well-Grounded Rubyist, Fourth Edition

A regular file is a filesystem entity that stores ordinary file data rather than representing a directory, device, socket, or other special type.

A regular file stores ordinary file data, unlike a directory or another special filesystem entity. Ruby identifies regular files with File.file?, allowing directory entries to be filtered before processing. section 12.4.1

Summing regular-file sizes

Build full paths from a directory's entries, remove hidden names, retain entries for which File.file? returns true, and add their sizes with File.size.

How The Well-Grounded Rubyist, Fourth Edition covers it

How deep it goes
Defines regular-file selection through File.file? and demonstrates size aggregation, without examining file contents or filesystem internals.
Examples
Uses hidden-entry filtering, full-path construction, glob patterns, File.file?, and File.size to total directory contents.
What you can do after
Apply it via Ruby's File.file? and File.size methods to select regular files and calculate their total bytes.
How it connects
Connects regular files with directories, directory entries, directory globbing, and file-size queries.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Rubyist, Fourth Edition. The section links point to the parts of the book it draws on.