ruby-changes:16813
From: akr <ko1@a...>
Date: Sat, 31 Jul 2010 23:16:26 +0900 (JST)
Subject: [ruby-changes:16813] Ruby:r28808 (trunk): * ext/pathname/pathname.c (path_inspect): Pathname#inspect translated
akr 2010-07-31 23:16:10 +0900 (Sat, 31 Jul 2010) New Revision: 28808 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28808 Log: * ext/pathname/pathname.c (path_inspect): Pathname#inspect translated from pathname.rb. Modified files: trunk/ChangeLog trunk/ext/pathname/lib/pathname.rb trunk/ext/pathname/pathname.c Index: ChangeLog =================================================================== --- ChangeLog (revision 28807) +++ ChangeLog (revision 28808) @@ -1,3 +1,8 @@ +Sat Jul 31 23:15:27 2010 Tanaka Akira <akr@f...> + + * ext/pathname/pathname.c (path_inspect): Pathname#inspect translated + from pathname.rb. + Sat Jul 31 15:50:03 2010 Tanaka Akira <akr@f...> * ext/pathname/pathname.c (Init_pathname): The alias, Index: ext/pathname/lib/pathname.rb =================================================================== --- ext/pathname/lib/pathname.rb (revision 28807) +++ ext/pathname/lib/pathname.rb (revision 28808) @@ -31,10 +31,6 @@ # :startdoc: - def inspect # :nodoc: - "#<#{self.class}:#{@path}>" - end - # Return a pathname which is substituted by String#sub. def sub(pattern, *rest, &block) if block Index: ext/pathname/pathname.c =================================================================== --- ext/pathname/pathname.c (revision 28807) +++ ext/pathname/pathname.c (revision 28808) @@ -141,6 +141,15 @@ 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 @@ 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); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/