Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Pathname#size

() -> ::Integer
size → integer

Returns the size in bytes of the entry at the path in self:

Example
Pathname('doc/maintainers.md').size # => 14900  # Regular file.
Pathname('doc/syntax/').size        # => 4096   # Directory.

Raises an exception if the entry does not exist.

See also #size? #setuid? #setgid? #socket? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0