diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-31 00:13:10 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-31 00:13:10 +0000 |
commit | c57e8f7ddc816746e0541c26a3df6cdbd65ba435 (patch) | |
tree | 0a55145c50b31e62ba87e70f9a66aaa4dff012f4 /ext | |
parent | faca64d5dd30b9db0bc54c80ad1835b626c461b1 (diff) | |
download | ruby-c57e8f7ddc816746e0541c26a3df6cdbd65ba435.tar.gz |
* ext/pathname/pathname.c (path_to_s): Pathname#to_s translated
from pathname.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/pathname/lib/pathname.rb | 5 | ||||
-rw-r--r-- | ext/pathname/pathname.c | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb index 75705ff993..550939afd9 100644 --- a/ext/pathname/lib/pathname.rb +++ b/ext/pathname/lib/pathname.rb @@ -31,11 +31,6 @@ class Pathname # :startdoc: - # Return the path as a String. - def to_s - @path.dup - end - # to_path is implemented so Pathname objects are usable with File.open, etc. alias_method TO_PATH, :to_s diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index f437d7f859..20c7745863 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -127,6 +127,15 @@ path_hash(VALUE self) } /* + * Return the path as a String. + */ +static VALUE +path_to_s(VALUE self) +{ + return rb_obj_dup(get_strpath(self)); +} + +/* * == Pathname * * Pathname represents a pathname which locates a file in a filesystem. @@ -319,4 +328,5 @@ Init_pathname() rb_define_method(rb_cPathname, "eql?", path_eq, 1); rb_define_method(rb_cPathname, "<=>", path_cmp, 1); rb_define_method(rb_cPathname, "hash", path_hash, 0); + rb_define_method(rb_cPathname, "to_s", path_to_s, 0); } |