Ruby verwendet File.open
Modi und Optionen als Argumente. Wo finde ich eine vollständige Liste der Modi und Optionen?
Ruby verwendet File.open
Modi und Optionen als Argumente. Wo finde ich eine vollständige Liste der Modi und Optionen?
Antworten:
In der Dokumentation zum Ruby IO-Modul , nehme ich an.
Mode | Meaning
-----+--------------------------------------------------------
"r" | Read-only, starts at beginning of file (default mode).
-----+--------------------------------------------------------
"r+" | Read-write, starts at beginning of file.
-----+--------------------------------------------------------
"w" | Write-only, truncates existing file
| to zero length or creates a new file for writing.
-----+--------------------------------------------------------
"w+" | Read-write, truncates existing file to zero length
| or creates a new file for reading and writing.
-----+--------------------------------------------------------
"a" | Write-only, starts at end of file if file exists,
| otherwise creates a new file for writing.
-----+--------------------------------------------------------
"a+" | Read-write, starts at end of file if file exists,
| otherwise creates a new file for reading and
| writing.
-----+--------------------------------------------------------
"b" | Binary file mode (may appear with
| any of the key letters listed above).
| Suppresses EOL <-> CRLF conversion on Windows. And
| sets external encoding to ASCII-8BIT unless explicitly
| specified.
-----+--------------------------------------------------------
"t" | Text file mode (may appear with
| any of the key letters listed above except "b").
File.open(filename, mode="r" [, opt])
in der Dokumentation nicht finden .
opt
ist neu für Ruby 1.9. Die verschiedenen Optionen sind dokumentiert unter IO.new
: www.ruby-doc.org/core/IO.html