Skip to content

Commit f7be281

Browse files
committed
[DOC] Clarify the conversion by File.path
1 parent 08af07b commit f7be281

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

file.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5196,6 +5196,22 @@ rb_file_s_extname(VALUE klass, VALUE fname)
51965196
* File.path(File::NULL) #=> "/dev/null"
51975197
* File.path(Pathname.new("/tmp")) #=> "/tmp"
51985198
*
5199+
* If +path+ is not a String:
5200+
*
5201+
* 1. If it has the +to_path+ method, that method will be called to
5202+
* coerce to a String.
5203+
*
5204+
* 2. Otherwise, or if the coerced result is not a String too, the
5205+
* standard coersion using +to_str+ method will take place on that
5206+
* object. (See also String.try_convert)
5207+
*
5208+
* The coerced string must satisfy the following conditions:
5209+
*
5210+
* 1. It must be in an ASCII-compatible encoding; otherwise, an
5211+
* Encoding::CompatibilityError is raised.
5212+
*
5213+
* 2. It must not contain the NUL character (<tt>\0</tt>); otherwise,
5214+
* an ArgumentError is raised.
51995215
*/
52005216

52015217
static VALUE

0 commit comments

Comments
 (0)