Class: Warts::Addr
Instance Attribute Summary collapse
- #element_type ⇒ Object readonly
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
rb_define_method(cAddr, “initialize_copy”, scaddr_init_copy, 1);.
- #addr ⇒ Object
- #initialize ⇒ Object constructor
- #write_to(file) ⇒ Object
Constructor Details
#initialize ⇒ Object
98 99 100 101 102 |
# File 'ext/scaddr.c', line 98
static VALUE scaddr_init(VALUE self)
{
rb_ivar_set(self, iv_element_type, INT2FIX(SCAMPER_FILE_OBJ_ADDR));
return self;
}
|
Instance Attribute Details
#element_type ⇒ Object (readonly)
Instance Method Details
#<=>(other) ⇒ Object
rb_define_method(cAddr, “initialize_copy”, scaddr_init_copy, 1);
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'ext/scaddr.c', line 127
static VALUE scaddr_cmp(VALUE self, VALUE other)
{
scamper_addr_t *self_addr;
scamper_addr_t *other_addr;
if (other == self) {
return INT2FIX(0);
}
/* See Pragmatic Programmer's book. */
if (TYPE(other) != T_DATA || RDATA(other)->dfree != scaddr_free) {
rb_raise(rb_eTypeError, "wrong argument type");
}
Data_Get_Struct(self, scamper_addr_t, self_addr);
Data_Get_Struct(other, scamper_addr_t, other_addr);
return INT2FIX(scamper_addr_cmp(self_addr, other_addr));
}
|
#addr ⇒ Object
147 148 149 150 151 152 153 154 |
# File 'ext/scaddr.c', line 147
static VALUE scaddr_addr(VALUE self)
{
scamper_addr_t *addr;
char buf[128];
Data_Get_Struct(self, scamper_addr_t, addr);
return rb_str_new2(scamper_addr_tostr(addr, buf, 128));
}
|
#write_to(file) ⇒ Object
157 158 159 160 |
# File 'ext/scaddr.c', line 157
static VALUE scaddr_write_to(VALUE self, VALUE file)
{
return self; /* nothing to do: users shouldn't write addrs themselves */
}
|