class Xmms::Collection

Constants

ADD
NS_ALL
NS_COLLECTIONS
NS_PLAYLISTS
REMOVE
RENAME
TYPE_COMPLEMENT
TYPE_EQUALS
TYPE_GREATER
TYPE_GREATEREQ
TYPE_HAS
TYPE_IDLIST
TYPE_INTERSECTION
TYPE_LIMIT
TYPE_MATCH
TYPE_MEDIASET
TYPE_NOTEQUAL
TYPE_ORDER
TYPE_REFERENCE
TYPE_SMALLER
TYPE_SMALLEREQ
TYPE_TOKEN
TYPE_UNION
TYPE_UNIVERSE
UPDATE

Public Class Methods

c = Xmms::Collection.new(type) click to toggle source

Returns a new Xmms::Collection object of type type.

static VALUE
c_coll_init (VALUE self, VALUE type)
{
        COLL_METHOD_HANDLER_HEADER

        coll->real = xmmsv_new_coll (check_int32 (type));

        return self;
}
c = Xmms::Collection.parse(pattern) click to toggle source

Returns a collection matching a String pattern. See the wiki for details on how to construct a pattern string.

static VALUE
c_coll_parse (VALUE klass, VALUE pattern)
{
        VALUE obj = rb_obj_alloc (klass);
        RbCollection *coll = NULL;

        Data_Get_Struct (obj, RbCollection, coll);

        if (!xmmsv_coll_parse (StringValuePtr (pattern), &coll->real)) {
                rb_raise (ePatternError, "invalid pattern");
        }

        return obj;
}
c = Xmms::Collection.universe click to toggle source

Returns a collection referencing the “All Media” set.

static VALUE
c_coll_universe (VALUE klass)
{
        VALUE obj = rb_obj_alloc (klass);
        RbCollection *coll = NULL;

        Data_Get_Struct (obj, RbCollection, coll);

        coll->real = xmmsv_new_coll (XMMS_COLLECTION_TYPE_UNIVERSE);

        return obj;
}

Public Instance Methods

&(other)
Alias for: intersect
and(other)
Alias for: intersect
attributes click to toggle source

Returns the attributes of the collection.

static VALUE
c_coll_attributes (VALUE self)
{
        RbCollection *coll = NULL;

        Data_Get_Struct (self, RbCollection, coll);

        if (NIL_P (coll->attributes))
                coll->attributes = rb_class_new_instance (1, &self, cAttributes);

        return coll->attributes;
}
complement → collection click to toggle source

Returns a new collection that is the logical complement of c.

# File src/clients/lib/ruby/xmmsclient.rb, line 49
def complement
        c = Xmms::Collection.new(Xmms::Collection::TYPE_COMPLEMENT)
        c.operands << self
        c
end
Also aliased as: not, ~
idlist click to toggle source

Gets the list of media ids that make up the collection.

static VALUE
c_coll_idlist_get (VALUE self)
{
        VALUE ary = rb_ary_new ();
        xmmsv_t *ret = NULL;
        xmmsv_list_iter_t *it = NULL;
        int32_t entry;

        COLL_METHOD_ADD_HANDLER_RET (idlist_get)

        xmmsv_get_list_iter (ret, &it);
        for (xmmsv_list_iter_first (it);
             xmmsv_list_iter_valid (it);
             xmmsv_list_iter_next (it)) {

                xmmsv_list_iter_entry_int (it, &entry);
                rb_ary_push (ary, INT2NUM (entry));
        }
        xmmsv_list_iter_explicit_destroy (it);

        return ary;
}
idlist=(_idlist_) click to toggle source

Sets the list of media ids that make up the collection.

static VALUE
c_coll_idlist_set (VALUE self, VALUE ids)
{
        int i;
        int *ary = NULL;
        VALUE *rb_ary;
        int rb_ary_len;

        Check_Type (ids, T_ARRAY);
        COLL_METHOD_HANDLER_HEADER

        rb_ary = RARRAY_PTR (ids);
        rb_ary_len = RARRAY_LEN (ids);

        ary = malloc (sizeof (int) * (rb_ary_len + 1));

        for (i = 0; i < rb_ary_len; i++)
                ary[i] = NUM2INT (rb_ary[i]);

        ary[i] = 0;

        xmmsv_coll_set_idlist (coll->real, ary);

        return self;
}
intersect(other) → collection click to toggle source

Returns a new collection that is the logical AND of c and other.

# File src/clients/lib/ruby/xmmsclient.rb, line 37
def intersect(other)
        c = Xmms::Collection.new(Xmms::Collection::TYPE_INTERSECTION)
        c.operands << self
        c.operands << other
        c
end
Also aliased as: and, &
not()
Alias for: complement
operands click to toggle source

Gets a list of the operands that make up the collection.

static VALUE
c_coll_operands (VALUE self)
{
        RbCollection *coll = NULL;

        Data_Get_Struct (self, RbCollection, coll);

        if (NIL_P (coll->operands))
                coll->operands = rb_class_new_instance (1, &self, cOperands);

        return coll->operands;
}
or(other)
Alias for: union
type click to toggle source

Returns the type of the collection as an Integer.

static VALUE
c_coll_type_get (VALUE self)
{
        xmmsc_coll_type_t ret;

        COLL_METHOD_ADD_HANDLER_RET (get_type)

        return INT2NUM (ret);
}
union(other) → collection click to toggle source

Returns a new collection that is the logical OR of c and other.

# File src/clients/lib/ruby/xmmsclient.rb, line 25
def union(other)
        c = Xmms::Collection.new(Xmms::Collection::TYPE_UNION)
        c.operands << self
        c.operands << other
        c
end
Also aliased as: or, |
|(other)
Alias for: union
~()
Alias for: complement