APIdock / Ruby
/
method

sub

ruby latest stable - Class: Pathname
sub(*args)
public

Return a pathname which is substituted by String#sub.

path1 = Pathname .new ('/usr/bin/perl')
path1.sub ('perl', 'ruby')
 #=> #<Pathname:/usr/bin/ruby>
static VALUE
path_sub(int argc, VALUE *argv, VALUE self)
{
 VALUE str = get_strpath(self);
 if (rb_block_given_p()) {
 str = rb_block_call(str, id_sub, argc, argv, 0, 0);
 }
 else {
 str = rb_funcallv(str, id_sub, argc, argv);
 }
 return rb_class_new_instance(1, &str, rb_obj_class(self));
}

AltStyle によって変換されたページ (->オリジナル) /