Method: Pathname#sub
- Defined in:
- pathname.c
#sub(*args) ⇒ Object
Return a pathname which is substituted by String#sub.
path1 = Pathname.new(‘/usr/bin/perl’) path1.sub(‘perl’, ‘ruby’)
#=> #<Pathname:/usr/bin/ruby>
196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'pathname.c', line 196
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, rb_intern("sub"), argc, argv, 0, 0);
}
else {
str = rb_funcall2(str, rb_intern("sub"), argc, argv);
}
return rb_class_new_instance(1, &str, rb_obj_class(self));
}
|