Class: Proc

Inherits:
Object show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#fileObject

Returns the file in which the proc body is defined, or nil



77
78
79
80
81
82
83
84
85
86
87
# File 'ext/utilrb_ext.cc', line 77

static VALUE proc_file(VALUE self)
{ 
    struct BLOCK *data;
    NODE *node;

    Data_Get_Struct(self, struct BLOCK, data);
    if ((node = data->frame.node) || (node = data->body)) 
	return rb_str_new2(node->nd_file);
    else 
	return Qnil;
}

#lineObject

Returns the line at which the proc body is defined, or nil



94
95
96
97
98
99
100
101
102
103
104
# File 'ext/utilrb_ext.cc', line 94

static VALUE proc_line(VALUE self)
{
    struct BLOCK *data;
    NODE *node;

    Data_Get_Struct(self, struct BLOCK, data);
    if ((node = data->frame.node) || (node = data->body)) 
	return INT2FIX(nd_line(node));
    else
	return Qnil;
}

#same_body?(other) ⇒ Boolean

Returns true if self and other have the same body

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
67
68
69
70
# File 'ext/utilrb_ext.cc', line 59

static VALUE proc_same_body_p(VALUE self, VALUE other)
{
    if (self == other) return Qtrue;
    if (TYPE(other) != T_DATA) return Qfalse;
    if (RDATA(other)->dmark != RDATA(self)->dmark) return Qfalse;
    if (CLASS_OF(self) != CLASS_OF(other)) return Qfalse;

    struct BLOCK* data, *data2;
    Data_Get_Struct(self, struct BLOCK, data);
    Data_Get_Struct(other, struct BLOCK, data2);
    return (data->body == data2->body) ? Qtrue : Qfalse;
}