class Curses::Item - curses-1.2.7 Documentation

# class Curses::Item

### Public Class Methods

new(name, description) click to toggle source

Construct a new Curses::Item.

    static VALUE
    item_initialize(VALUE obj, VALUE name, VALUE description)
    {
        struct itemdata *itemp;

        curses_init_screen();
        TypedData_Get_Struct(obj, struct itemdata, &itemdata_type, itemp);
        if (itemp->item) {
            rb_raise(rb_eRuntimeError, "already initialized item");
        }
        name = rb_str_export_to_enc(name, terminal_encoding);
        description = rb_str_export_to_enc(description, terminal_encoding);
        itemp->item = new_item(StringValueCStr(name),
                               StringValueCStr(description));
        if (itemp->item == NULL) {
            check_curses_error(errno);
        }

        return obj;
    }

### Public Instance Methods

==(p1) click to toggle source

    static VALUE
    item_eq(VALUE obj, VALUE other)
    {
        struct itemdata *item1, *item2;

        GetITEM(obj, item1);
        GetITEM(other, item2);
        return item1->item == item2->item ? Qtrue : Qfalse;
    }

description() click to toggle source

    static VALUE
    item_description_m(VALUE obj)
    {
        struct itemdata *itemp;
        const char *desc;

        GetITEM(obj, itemp);
        desc = item_description(itemp->item);
        return rb_external_str_new_with_enc(desc, strlen(desc), terminal_encoding);
    }

name() click to toggle source

    static VALUE
    item_name_m(VALUE obj)
    {
        struct itemdata *itemp;
        const char *name;

        GetITEM(obj, itemp);
        name = item_name(itemp->item);
        return rb_external_str_new_with_enc(name, strlen(name), terminal_encoding);
    }