class Cornflake

Public Class Methods

macaddr=(p1) click to toggle source
static VALUE
rb_cornflake_set_mac(VALUE klass, VALUE rb_mac)
{
        Check_Type(rb_mac, T_STRING);

        if (cornflake_set_mac(StringValueCStr(rb_mac)) < 0)
                rb_raise(rb_eTypeError, "Invalid MAC Address: %s", StringValueCStr(rb_mac));

        return Qnil;
}
new(p1) click to toggle source
static VALUE
rb_cornflake__new(VALUE klass, VALUE rb_path)
{
        struct cornflake *corn;

        Check_Type(rb_path, T_STRING);

        corn = cornflake_new(StringValueCStr(rb_path));
        if (!corn)
                rb_raise(rb_eRuntimeError, "Failed to open Cornflake state at %s",
                        StringValueCStr(rb_path));

        return Data_Wrap_Struct(klass, NULL, rb_cornflake__free, corn);
}

Public Instance Methods

base62() click to toggle source
# File lib/cornflake.rb, line 20
def base62
  Base62.encode(self.hex.to_i(16))
end
hex() click to toggle source
static VALUE
rb_cornflake_gen_hex(VALUE self)
{
        char hex_uid[33];
        struct cornflake *corn;

        Data_Get_Struct(self, struct cornflake, corn);
        rb_cornflake_check(cornflake_gen_hex(hex_uid, sizeof(hex_uid), corn));

        return rb_str_new2(hex_uid);
}
uid() click to toggle source
static VALUE
rb_cornflake_gen(VALUE self)
{
        uint8_t uid[16];
        struct cornflake *corn;

        Data_Get_Struct(self, struct cornflake, corn);
        rb_cornflake_check(cornflake_gen(uid, corn));

        return rb_str_new((char *)uid, 16);
}