end_with?(...)
public
Returns true if str ends with the suffix given.
Show source
/*
* call-seq:
* str.end_with?([suffix]+) => true or false
*
* Returns true if <i>str</i> ends with the suffix given.
*/
static VALUE
rb_str_end_with(argc, argv, str)
int argc;
VALUE *argv;
VALUE str;
{
int i;
long pos;
VALUE pat;
for (i=0; i<argc; i++) {
VALUE suffix = rb_check_string_type(argv[i]);
if (NIL_P(suffix)) continue;
if (RSTRING(str)->len < RSTRING(suffix)->len) continue;
pat = get_arg_pat(suffix);
pos = rb_reg_adjust_startpos(pat, str, RSTRING(str)->len - RSTRING(suffix)->len, 0);
if (rb_reg_search(pat, str, pos, 0) >= 0)
return Qtrue;
}
return Qfalse;
}