Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Pathname.new
new(p1)
ext/pathname/pathname.c
View on GitHub ↗
static VALUE
path_initialize(VALUE self, VALUE arg)
{
VALUE str;
if (RB_TYPE_P(arg, T_STRING)) {
str = arg;
}
else {
str = rb_check_funcall(arg, id_to_path, 0, NULL);
if (str == Qundef)
str = arg;
StringValue(str);
}
if (memchr(RSTRING_PTR(str), '\0', RSTRING_LEN(str)))
rb_raise(rb_eArgError, "pathname contains null byte");
str = rb_obj_dup(str);
set_strpath(self, str);
return self;
}
Create a Pathname object from the given String (or String-like object). If path contains a NULL character (\0), an ArgumentError is raised.