Class: Binyo::Byte

Inherits:
Object
  • Object
show all
Defined in:
ext/binyo/byte.c

Instance Method Summary collapse

Constructor Details

#initialize(byteval) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'ext/binyo/byte.c', line 67

static VALUE
binyo_byte_initialize(VALUE self, VALUE byteval)
{
    uint8_t *b;

    b = BINYO_ALLOC(uint8_t);
    *b = NUM2INT(byteval) & 0xff;
    DATA_PTR(self) = b;
    return self;
}

Instance Method Details

#&(vmask) ⇒ Object



87
88
89
90
91
92
93
94
# File 'ext/binyo/byte.c', line 87

static VALUE
binyo_byte_and(VALUE self, VALUE vmask)
{
    uint8_t *b;

    int_byte_get(self, b);
    return binyo_byte_new(*b & (NUM2INT(vmask)));
}

#>>(vshift) ⇒ Object



78
79
80
81
82
83
84
85
# File 'ext/binyo/byte.c', line 78

static VALUE
binyo_byte_shiftr(VALUE self, VALUE vshift)
{
    uint8_t *b;

    int_byte_get(self, b);
    return binyo_byte_new(*b >> (NUM2INT(vshift)));
}

#to_iObject



96
97
98
99
100
101
102
103
# File 'ext/binyo/byte.c', line 96

static VALUE
binyo_byte_to_i(VALUE self)
{
    uint8_t *b;

    int_byte_get(self, b);
    return INT2NUM(*b);
}