summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/pathname/lib/pathname.rb4
-rw-r--r--ext/pathname/pathname.c10
3 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ba6f702c69..e2e80883b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jul 31 23:15:27 2010 Tanaka Akira <akr@fsij.org>
+
+ * ext/pathname/pathname.c (path_inspect): Pathname#inspect translated
+ from pathname.rb.
+
Sat Jul 31 15:50:03 2010 Tanaka Akira <akr@fsij.org>
* ext/pathname/pathname.c (Init_pathname): The alias,
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);
}