diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-31 14:16:10 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-31 14:16:10 +0000 |
commit | b6ebd0622c0d730e5843dcb4dae1800fd5634884 (patch) | |
tree | 87df818b60026504abdc5c2820f64f8380ecc81f /ext | |
parent | 9006bd201535061bdf11192430432fee33bc9327 (diff) | |
download | ruby-b6ebd0622c0d730e5843dcb4dae1800fd5634884.tar.gz |
* ext/pathname/pathname.c (path_inspect): Pathname#inspect translated
from pathname.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/pathname/lib/pathname.rb | 4 | ||||
-rw-r--r-- | ext/pathname/pathname.c | 10 |
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); } |