Skip to content

Documentation


Documentation / @blazetrails/activesupport / Tempfile

Class: Tempfile ​

Defined in: packages/ruby-compat/dist/tempfile.d.ts:48

Ruby's Tempfile (stdlib vendor/ruby/v3.3.11/lib/tempfile.rb:89), which Rails calls from encrypted_file.rb:90, postgresql_database_tasks.rb:132 and core_ext/file/atomic.rb:24.

Tempfile < DelegateClass(File) (tempfile.rb:89), so every stream method it does not define is the File opened at tempfile.rb:157, cursor and all, handed to super at tempfile.rb:165.

open and create run a synchronous block inline and return its value directly, the way Ruby does (vendor/ruby/v3.3.11/lib/tempfile.rb:366, :438); an asynchronous block chains its ensure onto the Promise.

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile (vendor/ruby/v3.3.11/lib/tempfile.rb:89), which Rails calls without defining, so no Rails or gem file declares this class.

Extends ​

  • Tempfile_base

Properties ​

enc ​

protected enc: Encoding | null

Defined in: packages/ruby-compat/dist/io.d.ts:173

Inherited from ​

Tempfile_base.enc


enc2 ​

protected enc2: Encoding | null

Defined in: packages/ruby-compat/dist/io.d.ts:175

fptr->encs.enc2 (vendor/ruby/v3.3.11/io.c:11718).

Inherited from ​

Tempfile_base.enc2


fd ​

protected fd: number

Defined in: packages/ruby-compat/dist/io.d.ts:168

The descriptor rb_io_s_open (vendor/ruby/v3.3.11/io.c:8148) opened the stream on, and the offset rb_io_seek_m (io.c:2495) moves — Ruby's rb_io_t holds both.

Inherited from ​

Tempfile_base.fd


mode ​

protected mode: number

Defined in: packages/ruby-compat/dist/io.d.ts:172

fptr->mode, the FMODE_* flags (vendor/ruby/v3.3.11/io.c:6881).

Inherited from ​

Tempfile_base.mode


pathv ​

protected pathv: string | null

Defined in: packages/ruby-compat/dist/io.d.ts:170

fptr->pathv (vendor/ruby/v3.3.11/io.c:2943 reads it back as IO#path).

Inherited from ​

Tempfile_base.pathv


print ​

print: (this, ...args) => null

Defined in: packages/ruby-compat/dist/io.d.ts:688

rb_io_print (vendor/ruby/v3.3.11/io.c:8715) with $, nil: each argument's to_s, written with no separator, answering nil. Shared by IO#print and StringIO#print the way puts is.

Parameters ​

ParameterType
thisGenericWritable
...argsunknown[]

Returns ​

null

No Rails Equivalent ​

PERMANENT — Ruby core IO#print (vendor/ruby/v3.3.11/io.c:8715).

No Rails Equivalent ​

PERMANENT — Ruby core IO#print (vendor/ruby/v3.3.11/io.c:15457).

Inherited from ​

Tempfile_base.print


puts ​

puts: (this, ...args) => null

Defined in: packages/ruby-compat/dist/io.d.ts:683

rb_io_puts (vendor/ruby/v3.3.11/io.c:8947), reached both as IO#puts (io.c:15459) and, through IO::generic_writable, as StringIO#puts (vendor/ruby/v3.3.11/ext/stringio/stringio.c:1530) — one body, two receivers, which is why it lives here rather than beside StringIO.

Parameters ​

ParameterType
thisGenericWritable
...argsunknown[]

Returns ​

null

No Rails Equivalent ​

PERMANENT — Ruby core IO#puts (vendor/ruby/v3.3.11/io.c:8947).

No Rails Equivalent ​

PERMANENT — Ruby core IO#puts (vendor/ruby/v3.3.11/io.c:15459).

Inherited from ​

Tempfile_base.puts


stdioFile ​

protected stdioFile: WriteStream | null

Defined in: packages/ruby-compat/dist/io.d.ts:181

fptr->stdio_file (vendor/ruby/v3.3.11/io.c:9328), the C stream prep_stdio attaches to a standard descriptor. In trails the process adapter owns the standard streams, so a write reaches them through it rather than the fs.

Inherited from ​

Tempfile_base.stdioFile

Accessors ​

pos ​

Get Signature ​

get pos(): number

Defined in: packages/ruby-compat/dist/io.d.ts:438

vendor/ruby/v3.3.11/io.c:2039 rb_io_tell — the offset the next read or write starts at, which is what Rack::Test::UploadedFile#append_to leaves at 0 (vendor/rack-test/v2.2.0/lib/rack/test/uploaded_file.rb:66).

No Rails Equivalent ​

PERMANENT — Ruby core IO#pos (vendor/ruby/v3.3.11/io.c:2039).

Returns ​

number

Inherited from ​

Tempfile_base.pos


sync ​

Get Signature ​

get sync(): boolean

Defined in: packages/ruby-compat/dist/io.d.ts:197

vendor/ruby/v3.3.11/io.c:2703 rb_io_sync: whether the stream is in sync mode. write never buffers, so every stream behaves as a synced one.

No Rails Equivalent ​

PERMANENT — Ruby core IO#sync (vendor/ruby/v3.3.11/io.c:2703).

Returns ​

boolean

Set Signature ​

set sync(sync): void

Defined in: packages/ruby-compat/dist/io.d.ts:204

vendor/ruby/v3.3.11/io.c:2740 rb_io_set_sync.

No Rails Equivalent ​

PERMANENT — Ruby core IO#sync= (vendor/ruby/v3.3.11/io.c:2740).

Parameters ​
ParameterType
syncunknown
Returns ​

void

Inherited from ​

Tempfile_base.sync

Methods ​

__getobj__() ​

__getobj__(): File

Defined in: packages/ruby-compat/dist/tempfile.d.ts:28

Returns ​

File

Inherited from ​

Tempfile_base.__getobj__


__setobj__() ​

__setobj__(obj): void

Defined in: packages/ruby-compat/dist/tempfile.d.ts:29

Parameters ​

ParameterType
objunknown

Returns ​

void

Inherited from ​

Tempfile_base.__setobj__


append() ​

append(str): this

Defined in: packages/ruby-compat/dist/io.d.ts:650

IO#<< (vendor/ruby/v3.3.11/io.c:15501 rb_io_addstr, io.c:2323-2327).

Parameters ​

ParameterType
strstring | Uint8Array<ArrayBufferLike>

Returns ​

this

No Rails Equivalent ​

PERMANENT

Inherited from ​

Tempfile_base.append


binmode() ​

binmode(): this

Defined in: packages/ruby-compat/dist/io.d.ts:215

vendor/ruby/v3.3.11/io.c:6379 rb_io_binmode_m, which puts the stream in binary mode and answers the stream. A String written to a binary stream goes out as its own bytes rather than being transcoded, so after this write takes an ASCII-8BIT String — one character per byte, the encoding IO#read already answers in.

Returns ​

this

No Rails Equivalent ​

PERMANENT — Ruby core IO#binmode (vendor/ruby/v3.3.11/io.c:6379).

Inherited from ​

Tempfile_base.binmode


chmod() ​

chmod(mode): number

Defined in: packages/ruby-compat/dist/file.d.ts:640

vendor/ruby/v3.3.11/file.c:2599 rb_file_chmod, which answers 0. MRI calls fchmod(2) on the descriptor; the FsAdapter contract has no fchmodSync, so the open file's path takes the mode instead.

Parameters ​

ParameterType
modenumber

Returns ​

number

No Rails Equivalent ​

PERMANENT — Ruby core File#chmod (vendor/ruby/v3.3.11/file.c:2599).

Inherited from ​

Tempfile_base.chmod


close() ​

close(unlinkNow?): null

Defined in: packages/ruby-compat/dist/tempfile.d.ts:146

Tempfile#close(unlink_now = false) (vendor/ruby/v3.3.11/lib/tempfile.rb:208), whose _close (tempfile.rb:197) closes the delegated File.

Parameters ​

ParameterType
unlinkNow?boolean

Returns ​

null

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#close (vendor/ruby/v3.3.11/lib/tempfile.rb:208).

Overrides ​

Tempfile_base.close


closeBang() ​

closeBang(): true | null

Defined in: packages/ruby-compat/dist/tempfile.d.ts:153

Tempfile#close! (vendor/ruby/v3.3.11/lib/tempfile.rb:214).

Returns ​

true | null

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#close! (vendor/ruby/v3.3.11/lib/tempfile.rb:214).


delete() ​

delete(): true | null

Defined in: packages/ruby-compat/dist/tempfile.d.ts:170

alias delete unlink (vendor/ruby/v3.3.11/lib/tempfile.rb:264).

Returns ​

true | null

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#delete (vendor/ruby/v3.3.11/lib/tempfile.rb:264).


each() ​

Call Signature ​

each(): Generator<string | Uint8Array<ArrayBufferLike>>

Defined in: packages/ruby-compat/dist/io.d.ts:532

IO#each (vendor/ruby/v3.3.11/io.c:15462), defined onto rb_io_each_line.

Returns ​

Generator<string | Uint8Array<ArrayBufferLike>>

No Rails Equivalent ​

PERMANENT — Ruby core IO#each (vendor/ruby/v3.3.11/io.c:15462).

Inherited from ​

Tempfile_base.each

Call Signature ​

each(block): this

Defined in: packages/ruby-compat/dist/io.d.ts:533

IO#each (vendor/ruby/v3.3.11/io.c:15462), defined onto rb_io_each_line.

Parameters ​
ParameterType
block(line) => void
Returns ​

this

No Rails Equivalent ​

PERMANENT — Ruby core IO#each (vendor/ruby/v3.3.11/io.c:15462).

Inherited from ​

Tempfile_base.each


eachAsync() ​

eachAsync(): AsyncGenerator<string | Uint8Array<ArrayBufferLike>>

Defined in: packages/ruby-compat/dist/io.d.ts:542

each over the backend's async read: each line of the rest of the stream, its separator retained, read in chunks and never whole. Lines are split as bytes, so a character straddling two chunks survives.

Returns ​

AsyncGenerator<string | Uint8Array<ArrayBufferLike>>

No Rails Equivalent ​

PERMANENT — Ruby core IO#each (vendor/ruby/v3.3.11/io.c:15462).

Inherited from ​

Tempfile_base.eachAsync


eachLine() ​

Call Signature ​

eachLine(): Generator<string | Uint8Array<ArrayBufferLike>>

Defined in: packages/ruby-compat/dist/io.d.ts:524

IO#each_line (vendor/ruby/v3.3.11/io.c:4649 rb_io_each_line) with the default separator: each line of the rest of the stream yielded to the block and the receiver returned, or — with no block — a generator standing for RETURN_ENUMERATOR (io.c:4655), read when it is iterated.

Returns ​

Generator<string | Uint8Array<ArrayBufferLike>>

No Rails Equivalent ​

PERMANENT — Ruby core IO#each_line (vendor/ruby/v3.3.11/io.c:4649).

Inherited from ​

Tempfile_base.eachLine

Call Signature ​

eachLine(block): this

Defined in: packages/ruby-compat/dist/io.d.ts:525

IO#each_line (vendor/ruby/v3.3.11/io.c:4649 rb_io_each_line) with the default separator: each line of the rest of the stream yielded to the block and the receiver returned, or — with no block — a generator standing for RETURN_ENUMERATOR (io.c:4655), read when it is iterated.

Parameters ​
ParameterType
block(line) => void
Returns ​

this

No Rails Equivalent ​

PERMANENT — Ruby core IO#each_line (vendor/ruby/v3.3.11/io.c:4649).

Inherited from ​

Tempfile_base.eachLine


externalEncoding() ​

externalEncoding(): Encoding | null

Defined in: packages/ruby-compat/dist/io.d.ts:241

rb_io_external_encoding (vendor/ruby/v3.3.11/io.c:13407) — the transcoding pair's source encoding, the recorded one on a writable stream, and io_read_encoding (io.c:1010) on a readable one.

Returns ​

Encoding | null

No Rails Equivalent ​

PERMANENT — Ruby core IO#external_encoding (vendor/ruby/v3.3.11/io.c:13407).

Inherited from ​

Tempfile_base.externalEncoding


fileno() ​

fileno(): number

Defined in: packages/ruby-compat/dist/io.d.ts:419

vendor/ruby/v3.3.11/io.c:2858 rb_io_fileno — the integer descriptor the stream was opened on.

Returns ​

number

No Rails Equivalent ​

PERMANENT — Ruby core IO#fileno (vendor/ruby/v3.3.11/io.c:2858).

Inherited from ​

Tempfile_base.fileno


flock() ​

flock(operation): number | false

Defined in: packages/ruby-compat/dist/file.d.ts:622

vendor/ruby/v3.3.11/file.c:5301 rb_file_flock, which answers 0 once the lock is held. A backend with no advisory locking — node's fs exposes no flock(2) — has no flockSync, and there the stream is left unlocked, which is what an unlockable file already behaves like.

Parameters ​

ParameterType
operationnumber

Returns ​

number | false

No Rails Equivalent ​

PERMANENT — Ruby core File#flock (vendor/ruby/v3.3.11/file.c:5301).

Inherited from ​

Tempfile_base.flock


flush() ​

flush(): this

Defined in: packages/ruby-compat/dist/io.d.ts:678

vendor/ruby/v3.3.11/io.c:2379 rb_io_flush, which answers the stream. write holds no buffer.

Returns ​

this

No Rails Equivalent ​

PERMANENT — Ruby core IO#flush (vendor/ruby/v3.3.11/io.c:2379).

Inherited from ​

Tempfile_base.flush


gets() ​

gets(sep?, limit?, opts?): string | Uint8Array<ArrayBufferLike> | null

Defined in: packages/ruby-compat/dist/io.d.ts:554

rb_io_gets_m (vendor/ruby/v3.3.11/io.c:4363): the bytes up to and including the next sep ($/, "\n", by default), or the rest of the stream, in the external encoding as readAll answers it; nil at EOF. limit caps the bytes read ("" for 0), and chomp: true drops the trailing sep, with a \r before the default "\n" (rb_io_getline_0, vendor/ruby/v3.3.11/io.c:4128).

Parameters ​

ParameterType
sep?string | number | { chomp?: boolean; }
limit?number | { chomp?: boolean; } | null
opts?{ chomp?: boolean; }
opts.chomp?boolean

Returns ​

string | Uint8Array<ArrayBufferLike> | null

No Rails Equivalent ​

PERMANENT — Ruby core IO#gets (vendor/ruby/v3.3.11/io.c:4363).

Inherited from ​

Tempfile_base.gets


inspect() ​

inspect(): string

Defined in: packages/ruby-compat/dist/tempfile.d.ts:131

Tempfile#inspect (vendor/ruby/v3.3.11/lib/tempfile.rb:284).

Returns ​

string

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#inspect (vendor/ruby/v3.3.11/lib/tempfile.rb:284).


internalEncoding() ​

internalEncoding(): Encoding | null

Defined in: packages/ruby-compat/dist/io.d.ts:249

rb_io_internal_encoding (vendor/ruby/v3.3.11/io.c:13440) — the transcoding pair's destination encoding, and nil where no conversion is specified.

Returns ​

Encoding | null

No Rails Equivalent ​

PERMANENT — Ruby core IO#internal_encoding (vendor/ruby/v3.3.11/io.c:13440).

Inherited from ​

Tempfile_base.internalEncoding


ioSetEncodingByBom() ​

protected ioSetEncodingByBom(): Encoding | null

Defined in: packages/ruby-compat/dist/io.d.ts:614

io_set_encoding_by_bom (vendor/ruby/v3.3.11/io.c:7148-7163), which rb_file_open_generic runs under FMODE_SETENC_BY_BOM (io.c:7196).

Returns ​

Encoding | null

Inherited from ​

Tempfile_base.ioSetEncodingByBom


isBinmode() ​

isBinmode(): boolean

Defined in: packages/ruby-compat/dist/io.d.ts:257

vendor/ruby/v3.3.11/io.c:6400 rb_io_binmode_p, which answers whether FMODE_BINMODE is set on the stream.

Returns ​

boolean

No Rails Equivalent ​

PERMANENT — Ruby core IO#binmode? (vendor/ruby/v3.3.11/io.c:6400).

Inherited from ​

Tempfile_base.isBinmode


isClosed() ​

isClosed(): boolean

Defined in: packages/ruby-compat/dist/io.d.ts:454

vendor/ruby/v3.3.11/io.c:5842 rb_io_closed_p, which is fptr->fd < 0 — the same test rb_io_close_m (io.c:5779) short-circuits on.

Returns ​

boolean

No Rails Equivalent ​

PERMANENT — Ruby core IO#closed? (vendor/ruby/v3.3.11/io.c:5842).

Inherited from ​

Tempfile_base.isClosed


isEof() ​

isEof(): boolean

Defined in: packages/ruby-compat/dist/io.d.ts:644

vendor/ruby/v3.3.11/io.c:2668 rb_io_eof — true when io_fillbuf cannot get a byte at the current offset. There is no read buffer behind an FsAdapter, so the two READ_*_PENDING short-circuits (io.c:2674-2675) have nothing to answer for and the fill is a one-byte read that leaves the offset alone.

Returns ​

boolean

No Rails Equivalent ​

PERMANENT — Ruby core IO#eof? (vendor/ruby/v3.3.11/io.c:2668).

Inherited from ​

Tempfile_base.isEof


isTty() ​

isTty(): boolean

Defined in: packages/ruby-compat/dist/io.d.ts:461

IO#tty? (vendor/ruby/v3.3.11/io.c:5270 rb_io_isatty): whether the descriptor is a terminal. Only a standard stream's adapter can tell.

Returns ​

boolean

No Rails Equivalent ​

PERMANENT

Inherited from ​

Tempfile_base.isTty


length() ​

length(): number

Defined in: packages/ruby-compat/dist/tempfile.d.ts:124

alias length size (vendor/ruby/v3.3.11/lib/tempfile.rb:281).

Returns ​

number

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#length (vendor/ruby/v3.3.11/lib/tempfile.rb:281).


open() ​

open(): File

Defined in: packages/ruby-compat/dist/tempfile.d.ts:107

Tempfile#open (vendor/ruby/v3.3.11/lib/tempfile.rb:188) — closes the delegated File and reopens the same path with the creation flags cleared, which is mode "r+", then answers the reopened stream (tempfile.rb:194__getobj__).

Returns ​

File

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#open (vendor/ruby/v3.3.11/lib/tempfile.rb:188).


path() ​

path(): string | null

Defined in: packages/ruby-compat/dist/tempfile.d.ts:97

Tempfile#path (vendor/ruby/v3.3.11/lib/tempfile.rb:268) — __getobj__.path, and nil once unlink has run.

Returns ​

string | null

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#path (vendor/ruby/v3.3.11/lib/tempfile.rb:268).

Overrides ​

Tempfile_base.path


pread() ​

pread(maxlen, offset): Uint8Array

Defined in: packages/ruby-compat/dist/io.d.ts:514

rb_io_pread (vendor/ruby/v3.3.11/io.c:6202): maxlen bytes read at offset without moving the stream's position, raising EOFError when nothing is there to read.

Parameters ​

ParameterType
maxlennumber
offsetnumber

Returns ​

Uint8Array

No Rails Equivalent ​

PERMANENT — Ruby core IO#pread (vendor/ruby/v3.3.11/io.c:6202).

Inherited from ​

Tempfile_base.pread


read() ​

Call Signature ​

read(): string | Uint8Array<ArrayBufferLike>

Defined in: packages/ruby-compat/dist/io.d.ts:493

vendor/ruby/v3.3.11/io.c:3774 io_read, which behaves like C's fread and so retries read(2) until length bytes are in hand or the stream hits EOF (io.c:3760-3763) — a short read is not an answer. It answers nil — never "" — once the stream is at EOF and length is positive. The bytes come back as a binary String, one character per byte, whatever the stream's mode: the length arm buffers into rb_str_new (io_setstrbuf, io.c:3278), which is ASCII-8BIT, and never re-tags it — only the no-argument arm reaches the external encoding. It is assembled a character at a time because no TextDecoder encoding gives ASCII-8BIT: its "latin1" is windows-1252, and that remaps 0x80-0x9F.

The str buffer of io_read's two-argument form (io.c:3778rb_scan_args) receives the bytes, as io_setstrbuf (io.c:3278) fills it. Ruby resizes the String to the byte count it read; a Uint8Array cannot be resized, so it is filled up to its own length instead and the bytes still come back as the return value; at EOF, where rb_str_resize(str, 0) (io.c:3800) empties the String before the nil, it is zero-filled.

Returns ​

string | Uint8Array<ArrayBufferLike>

No Rails Equivalent ​

PERMANENT — Ruby core IO#read (vendor/ruby/v3.3.11/io.c:3774).

Inherited from ​

Tempfile_base.read

Call Signature ​

read(length, str?): string | Uint8Array<ArrayBufferLike>

Defined in: packages/ruby-compat/dist/io.d.ts:494

vendor/ruby/v3.3.11/io.c:3774 io_read, which behaves like C's fread and so retries read(2) until length bytes are in hand or the stream hits EOF (io.c:3760-3763) — a short read is not an answer. It answers nil — never "" — once the stream is at EOF and length is positive. The bytes come back as a binary String, one character per byte, whatever the stream's mode: the length arm buffers into rb_str_new (io_setstrbuf, io.c:3278), which is ASCII-8BIT, and never re-tags it — only the no-argument arm reaches the external encoding. It is assembled a character at a time because no TextDecoder encoding gives ASCII-8BIT: its "latin1" is windows-1252, and that remaps 0x80-0x9F.

The str buffer of io_read's two-argument form (io.c:3778rb_scan_args) receives the bytes, as io_setstrbuf (io.c:3278) fills it. Ruby resizes the String to the byte count it read; a Uint8Array cannot be resized, so it is filled up to its own length instead and the bytes still come back as the return value; at EOF, where rb_str_resize(str, 0) (io.c:3800) empties the String before the nil, it is zero-filled.

Parameters ​
ParameterType
lengthnull
str?Uint8Array<ArrayBufferLike> | null
Returns ​

string | Uint8Array<ArrayBufferLike>

No Rails Equivalent ​

PERMANENT — Ruby core IO#read (vendor/ruby/v3.3.11/io.c:3774).

Inherited from ​

Tempfile_base.read

Call Signature ​

read(length, str?): Uint8Array<ArrayBufferLike> | null

Defined in: packages/ruby-compat/dist/io.d.ts:495

vendor/ruby/v3.3.11/io.c:3774 io_read, which behaves like C's fread and so retries read(2) until length bytes are in hand or the stream hits EOF (io.c:3760-3763) — a short read is not an answer. It answers nil — never "" — once the stream is at EOF and length is positive. The bytes come back as a binary String, one character per byte, whatever the stream's mode: the length arm buffers into rb_str_new (io_setstrbuf, io.c:3278), which is ASCII-8BIT, and never re-tags it — only the no-argument arm reaches the external encoding. It is assembled a character at a time because no TextDecoder encoding gives ASCII-8BIT: its "latin1" is windows-1252, and that remaps 0x80-0x9F.

The str buffer of io_read's two-argument form (io.c:3778rb_scan_args) receives the bytes, as io_setstrbuf (io.c:3278) fills it. Ruby resizes the String to the byte count it read; a Uint8Array cannot be resized, so it is filled up to its own length instead and the bytes still come back as the return value; at EOF, where rb_str_resize(str, 0) (io.c:3800) empties the String before the nil, it is zero-filled.

Parameters ​
ParameterType
lengthnumber
str?Uint8Array<ArrayBufferLike> | null
Returns ​

Uint8Array<ArrayBufferLike> | null

No Rails Equivalent ​

PERMANENT — Ruby core IO#read (vendor/ruby/v3.3.11/io.c:3774).

Inherited from ​

Tempfile_base.read

Call Signature ​

read(length, str?): string | Uint8Array<ArrayBufferLike> | null

Defined in: packages/ruby-compat/dist/io.d.ts:496

vendor/ruby/v3.3.11/io.c:3774 io_read, which behaves like C's fread and so retries read(2) until length bytes are in hand or the stream hits EOF (io.c:3760-3763) — a short read is not an answer. It answers nil — never "" — once the stream is at EOF and length is positive. The bytes come back as a binary String, one character per byte, whatever the stream's mode: the length arm buffers into rb_str_new (io_setstrbuf, io.c:3278), which is ASCII-8BIT, and never re-tags it — only the no-argument arm reaches the external encoding. It is assembled a character at a time because no TextDecoder encoding gives ASCII-8BIT: its "latin1" is windows-1252, and that remaps 0x80-0x9F.

The str buffer of io_read's two-argument form (io.c:3778rb_scan_args) receives the bytes, as io_setstrbuf (io.c:3278) fills it. Ruby resizes the String to the byte count it read; a Uint8Array cannot be resized, so it is filled up to its own length instead and the bytes still come back as the return value; at EOF, where rb_str_resize(str, 0) (io.c:3800) empties the String before the nil, it is zero-filled.

Parameters ​
ParameterType
lengthnumber | null
str?Uint8Array<ArrayBufferLike> | null
Returns ​

string | Uint8Array<ArrayBufferLike> | null

No Rails Equivalent ​

PERMANENT — Ruby core IO#read (vendor/ruby/v3.3.11/io.c:3774).

Inherited from ​

Tempfile_base.read


readAsync() ​

Call Signature ​

readAsync(length?): Promise<string | Uint8Array<ArrayBufferLike>>

Defined in: packages/ruby-compat/dist/io.d.ts:504

read over the backend's async read: with no length, the rest of the stream in the external encoding, as readAll.

Parameters ​
ParameterType
length?null
Returns ​

Promise<string | Uint8Array<ArrayBufferLike>>

No Rails Equivalent ​

PERMANENT — Ruby core IO#read (vendor/ruby/v3.3.11/io.c:3774).

Inherited from ​

Tempfile_base.readAsync

Call Signature ​

readAsync(length): Promise<Uint8Array<ArrayBufferLike> | null>

Defined in: packages/ruby-compat/dist/io.d.ts:505

read over the backend's async read: with no length, the rest of the stream in the external encoding, as readAll.

Parameters ​
ParameterType
lengthnumber
Returns ​

Promise<Uint8Array<ArrayBufferLike> | null>

No Rails Equivalent ​

PERMANENT — Ruby core IO#read (vendor/ruby/v3.3.11/io.c:3774).

Inherited from ​

Tempfile_base.readAsync


readline() ​

readline(sep?): string | Uint8Array<ArrayBufferLike>

Defined in: packages/ruby-compat/dist/io.d.ts:583

IO#readline (vendor/ruby/v3.3.11/io.rb:133): io_readline (vendor/ruby/v3.3.11/io.c:4414) is gets that raises EOFError through rb_eof_error where gets answers nil.

Parameters ​

ParameterType
sep?string

Returns ​

string | Uint8Array<ArrayBufferLike>

No Rails Equivalent ​

PERMANENT — Ruby core IO#readline (vendor/ruby/v3.3.11/io.rb:133).

Inherited from ​

Tempfile_base.readline


readlines() ​

readlines(sep?, limit?, opts?): (string | Uint8Array<ArrayBufferLike>)[]

Defined in: packages/ruby-compat/dist/io.d.ts:568

rb_io_readlines (vendor/ruby/v3.3.11/io.c:4518) through io_readlines (io.c:4527): every remaining line, read as gets reads one.

Parameters ​

ParameterType
sep?string | number | { chomp?: boolean; }
limit?number | { chomp?: boolean; } | null
opts?{ chomp?: boolean; }
opts.chomp?boolean

Returns ​

(string | Uint8Array<ArrayBufferLike>)[]

No Rails Equivalent ​

PERMANENT — Ruby core IO#readlines (vendor/ruby/v3.3.11/io.c:4518).

Inherited from ​

Tempfile_base.readlines


readpartial() ​

readpartial(maxlen, outbuf?): Uint8Array

Defined in: packages/ruby-compat/dist/io.d.ts:634

vendor/ruby/v3.3.11/io.c:3590 io_readpartial, which is io_getpartial with a rb_eof_error() (io.c:756) where that answers nil — so it reads at most maxlen bytes and raises EOFError rather than returning nil at the end of the stream. outbuf is the buffer io_getpartial fills, the same str read takes.

A blocking descriptor read already returns what is available, so io_getpartial's short read IS read's length arm here.

Parameters ​

ParameterType
maxlennumber
outbuf?Uint8Array<ArrayBufferLike> | null

Returns ​

Uint8Array

No Rails Equivalent ​

PERMANENT — Ruby core IO#readpartial (vendor/ruby/v3.3.11/io.c:3590).

Inherited from ​

Tempfile_base.readpartial


reopen() ​

reopen(nfile): this

Defined in: packages/ruby-compat/dist/io.d.ts:711

IO#reopen(other_io) (vendor/ruby/v3.3.11/io.c:8316 io_reopen). JS has no dup2(2), so the stream takes other_io's descriptor rather than a copy of it, and other_io has to stay open for as long as this stream writes to it. A descriptor's kernel offset is shared but pos is per IO and writes are positional, so the two IOs do not advance each other. A child spawned with inherited stdio gets STDOUT and STDERR by fileno, so it follows the reopen as it follows the dup2 in Ruby.

Parameters ​

ParameterType
nfile{ toIo: IO; }
nfile.toIo

Returns ​

this

No Rails Equivalent ​

PERMANENT

Inherited from ​

Tempfile_base.reopen


rewind() ​

rewind(): number

Defined in: packages/ruby-compat/dist/io.d.ts:446

vendor/ruby/v3.3.11/io.c:2565 rb_io_rewind — the offset goes back to the start of the stream, and it answers 0.

Returns ​

number

No Rails Equivalent ​

PERMANENT — Ruby core IO#rewind (vendor/ruby/v3.3.11/io.c:2565).

Inherited from ​

Tempfile_base.rewind


seek() ​

seek(amount, whence?): number

Defined in: packages/ruby-compat/dist/io.d.ts:429

vendor/ruby/v3.3.11/io.c:2495 rb_io_seek_m: whence defaults to IO::SEEK_SET, the absolute offset the next read starts at; SEEK_CUR is relative to the current position and SEEK_END to the stream's size. It answers 0.

Parameters ​

ParameterType
amountnumber
whence?number

Returns ​

number

No Rails Equivalent ​

PERMANENT — Ruby core IO#seek (vendor/ruby/v3.3.11/io.c:2495).

Inherited from ​

Tempfile_base.seek


setEncoding() ​

setEncoding(extEnc, intEnc?): this

Defined in: packages/ruby-compat/dist/io.d.ts:232

vendor/ruby/v3.3.11/io.c:13474 rb_io_set_encoding — the external encoding the stream reads and writes through, which binmode also sets but which carries no FMODE_BINMODE of its own, and, in the two-argument form, the internal one it transcodes to. It answers the stream.

io_encoding_set (vendor/ruby/v3.3.11/io.c:11659) records whatever find_encoding answered, so a name that resolves to UNSPECIFIED_ENCODING — the internal alias while Encoding.default_internal is unset (ruby -e 'p STDOUT.set_encoding("internal").external_encoding' answers nil) — leaves the stream with no external encoding.

Parameters ​

ParameterType
extEncstring | Encoding
intEnc?string | Encoding

Returns ​

this

No Rails Equivalent ​

PERMANENT — Ruby core IO#set_encoding (vendor/ruby/v3.3.11/io.c:13474).

Inherited from ​

Tempfile_base.setEncoding


size() ​

size(): number

Defined in: packages/ruby-compat/dist/tempfile.d.ts:117

Tempfile#size (vendor/ruby/v3.3.11/lib/tempfile.rb:274) — File#size of the delegated open stream, and File.size of the path once it is closed, which is how Rack::Test::Utils#build_file_part fills content-length (vendor/rack-test/v2.2.0/lib/rack/test/utils.rb:143).

Returns ​

number

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#size (vendor/ruby/v3.3.11/lib/tempfile.rb:274).

Overrides ​

Tempfile_base.size


stat() ​

stat(): FsStatResult

Defined in: packages/ruby-compat/dist/io.d.ts:470

vendor/ruby/v3.3.11/io.c:2075 rb_io_stat — fstat(2) of the descriptor, where File.stat names a path. It raises on a closed stream, and on an adapter with no fstat there is no descriptor identity to answer with.

Returns ​

FsStatResult

No Rails Equivalent ​

PERMANENT — Ruby core IO#stat (vendor/ruby/v3.3.11/io.c:2075).

Inherited from ​

Tempfile_base.stat


toIo() ​

toIo(): this

Defined in: packages/ruby-compat/dist/io.d.ts:280

vendor/ruby/v3.3.11/io.c:5093 rb_io_to_io, which answers the stream itself.

Returns ​

this

No Rails Equivalent ​

PERMANENT — Ruby core IO#to_io (vendor/ruby/v3.3.11/io.c:5093).

Inherited from ​

Tempfile_base.toIo


toPath() ​

toPath(): string | null

Defined in: packages/ruby-compat/dist/io.d.ts:273

vendor/ruby/v3.3.11/io.c:2943 rb_io_path, registered as IO#to_path (io.c:15545).

Returns ​

string | null

No Rails Equivalent ​

PERMANENT — Ruby core IO#to_path (vendor/ruby/v3.3.11/io.c:15545).

Inherited from ​

Tempfile_base.toPath


toString() ​

toString(): string

Defined in: packages/ruby-compat/dist/tempfile.d.ts:138

alias to_s inspect (vendor/ruby/v3.3.11/lib/tempfile.rb:291).

Returns ​

string

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#to_s (vendor/ruby/v3.3.11/lib/tempfile.rb:291).


unlink(): true | null

Defined in: packages/ruby-compat/dist/tempfile.d.ts:163

Tempfile#unlink (vendor/ruby/v3.3.11/lib/tempfile.rb:252) — swallows Errno::ENOENT, and returns without marking the file unlinked on Errno::EACCES, which is Windows refusing to unlink an open file (tempfile.rb:255-259).

Returns ​

true | null

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile#unlink (vendor/ruby/v3.3.11/lib/tempfile.rb:252).


write() ​

write(string): number

Defined in: packages/ruby-compat/dist/io.d.ts:663

vendor/ruby/v3.3.11/io.c:2263 io_write_m in its one-argument form, which answers the number of bytes written. On a binary stream — binmode, or a mode carrying b (rb_io_binmode, io.c:6311) — string goes out as its own bytes, its UTF-8; otherwise do_writeconv (io.c:1904) transcodes it to the external encoding. A Uint8Array is a String's bytes already and goes out unchanged, which is how an ASCII-8BIT producer hands over its bytes.

Parameters ​

ParameterType
stringstring | Uint8Array<ArrayBufferLike>

Returns ​

number

No Rails Equivalent ​

PERMANENT — Ruby core IO#write (vendor/ruby/v3.3.11/io.c:2263).

Inherited from ​

Tempfile_base.write


writeAsync() ​

writeAsync(string): Promise<number>

Defined in: packages/ruby-compat/dist/io.d.ts:670

write over the backend's async write.

Parameters ​

ParameterType
stringstring | Uint8Array<ArrayBufferLike>

Returns ​

Promise<number>

No Rails Equivalent ​

PERMANENT — Ruby core IO#write (vendor/ruby/v3.3.11/io.c:2263).

Inherited from ​

Tempfile_base.writeAsync


create() ​

Call Signature ​

static create(basename?, tmpdir?): File

Defined in: packages/ruby-compat/dist/tempfile.d.ts:88

Tempfile.create (vendor/ruby/v3.3.11/lib/tempfile.rb:438), which is NOT a Tempfile: it opens a plain File (tempfile.rb:444) and yields or returns that, so the caller gets no finalizer and no Tempfile surface. The ensure unlinks BEFORE closing while the path still names the open file (tempfile.rb:449-453), which is the unlink-after-creation practice Tempfile.create exists to give on POSIX, and falls back to unlinking after the close when that did not happen (tempfile.rb:455-460).

Parameters ​
ParameterType
basename?TempfileBasename
tmpdir?string
Returns ​

File

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile.create (vendor/ruby/v3.3.11/lib/tempfile.rb:438).

Call Signature ​

static create<T>(basename, tmpdir, block): T

Defined in: packages/ruby-compat/dist/tempfile.d.ts:89

Tempfile.create (vendor/ruby/v3.3.11/lib/tempfile.rb:438), which is NOT a Tempfile: it opens a plain File (tempfile.rb:444) and yields or returns that, so the caller gets no finalizer and no Tempfile surface. The ensure unlinks BEFORE closing while the path still names the open file (tempfile.rb:449-453), which is the unlink-after-creation practice Tempfile.create exists to give on POSIX, and falls back to unlinking after the close when that did not happen (tempfile.rb:455-460).

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
basenameTempfileBasename | undefined
tmpdirstring | undefined
block(tmpfile) => T
Returns ​

T

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile.create (vendor/ruby/v3.3.11/lib/tempfile.rb:438).


new() ​

static new(basename?, tmpdir?, options?): Tempfile

Defined in: packages/ruby-compat/dist/tempfile.d.ts:64

Tempfile#initialize (vendor/ruby/v3.3.11/lib/tempfile.rb:150) — the name comes from Dir::Tmpname.create, and the file is opened RDWR|CREAT|EXCL (tempfile.rb:154) with perm: 0600 (tempfile.rb:158).

Parameters ​

ParameterType
basename?TempfileBasename
tmpdir?string | null
options?TempfileOptions

Returns ​

Tempfile

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile.new (vendor/ruby/v3.3.11/lib/tempfile.rb:150).


open() ​

Call Signature ​

static open(basename?, tmpdir?, options?): Tempfile

Defined in: packages/ruby-compat/dist/tempfile.d.ts:73

Tempfile.open (vendor/ruby/v3.3.11/lib/tempfile.rb:366) — with a block, yields the tempfile and closes it in an ensure (tempfile.rb:369-374), leaving the file in place; without one, returns the tempfile.

Parameters ​
ParameterType
basename?TempfileBasename
tmpdir?string
options?TempfileOptions
Returns ​

Tempfile

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile.open (vendor/ruby/v3.3.11/lib/tempfile.rb:366).

Call Signature ​

static open<T>(basename, tmpdir, block): T

Defined in: packages/ruby-compat/dist/tempfile.d.ts:74

Tempfile.open (vendor/ruby/v3.3.11/lib/tempfile.rb:366) — with a block, yields the tempfile and closes it in an ensure (tempfile.rb:369-374), leaving the file in place; without one, returns the tempfile.

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
basenameTempfileBasename | undefined
tmpdirstring | undefined
block(tempfile) => T
Returns ​

T

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile.open (vendor/ruby/v3.3.11/lib/tempfile.rb:366).

Call Signature ​

static open<T>(basename, tmpdir, options, block): T

Defined in: packages/ruby-compat/dist/tempfile.d.ts:75

Tempfile.open (vendor/ruby/v3.3.11/lib/tempfile.rb:366) — with a block, yields the tempfile and closes it in an ensure (tempfile.rb:369-374), leaving the file in place; without one, returns the tempfile.

Type Parameters ​
Type Parameter
T
Parameters ​
ParameterType
basenameTempfileBasename | undefined
tmpdirstring | undefined
optionsTempfileOptions
block(tempfile) => T
Returns ​

T

No Rails Equivalent ​

PERMANENT — Ruby stdlib Tempfile.open (vendor/ruby/v3.3.11/lib/tempfile.rb:366).