Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
File#size
() -> ::Integer
size → integer
file.c
View on GitHub ↗
static VALUE
file_size(VALUE self)
{
return OFFT2NUM(rb_file_size(self));
}
Returns the size of self in bytes:
Example
File.new('doc/maintainers.md').size # => 14900 # Regular file. File.new('doc/syntax/').size # => 4096 # Directory.