summaryrefslogtreecommitdiff
path: root/ext/pathname
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pathname')
-rw-r--r--ext/pathname/lib/pathname.rb4
-rw-r--r--ext/pathname/pathname.c10
2 files changed, 10 insertions, 4 deletions
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb
index 57e410f345..88453c3c66 100644
--- a/ext/pathname/lib/pathname.rb
+++ b/ext/pathname/lib/pathname.rb
@@ -31,10 +31,6 @@ class Pathname
# :startdoc:
- def inspect # :nodoc:
- "#<#{self.class}:#{@path}>"
- end
-
# Return a pathname which is substituted by String#sub.
def sub(pattern, *rest, &block)
if block
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 02f964058e..5c3620e2b5 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -141,6 +141,15 @@ path_to_s(VALUE self)
return rb_obj_dup(get_strpath(self));
}
+/* :nodoc: */
+static VALUE
+path_inspect(VALUE self)
+{
+ const char *c = rb_obj_classname(self);
+ VALUE str = get_strpath(self);
+ return rb_sprintf("#<%s:%s>", c, RSTRING_PTR(str));
+}
+
/*
* == Pathname
*
@@ -336,4 +345,5 @@ Init_pathname()
rb_define_method(rb_cPathname, "hash", path_hash, 0);
rb_define_method(rb_cPathname, "to_s", path_to_s, 0);
rb_define_method(rb_cPathname, "to_path", path_to_s, 0);
+ rb_define_method(rb_cPathname, "inspect", path_inspect, 0);
}