class Xmms::Collection::Attributes
Public Class Methods
new(p1)
click to toggle source
static VALUE
c_attrs_init (VALUE self, VALUE collection)
{
rb_iv_set (self, "collection", collection);
return self;
}
Public Instance Methods
[](p1)
click to toggle source
HAVE_RB_PROTECT_INSPECT
static VALUE
c_attrs_aref (VALUE self, VALUE key)
{
RbCollection *coll = NULL;
VALUE tmp;
int s;
const char *value;
StringValue (key);
tmp = rb_iv_get (self, "collection");
Data_Get_Struct (tmp, RbCollection, coll);
s = xmmsv_coll_attribute_get_string (coll->real, StringValuePtr (key), &value);
if (!s)
return Qnil;
return rb_str_new2 (value);
}
[]=(p1, p2)
click to toggle source
static VALUE
c_attrs_aset (VALUE self, VALUE key, VALUE value)
{
RbCollection *coll = NULL;
VALUE tmp;
StringValue (key);
StringValue (value);
tmp = rb_iv_get (self, "collection");
Data_Get_Struct (tmp, RbCollection, coll);
xmmsv_coll_attribute_set_string (coll->real, StringValuePtr (key),
StringValuePtr (value));
return Qnil;
}
delete(p1)
click to toggle source
static VALUE
c_attrs_delete (VALUE self, VALUE key)
{
RbCollection *coll = NULL;
VALUE tmp;
StringValue (key);
tmp = rb_iv_get (self, "collection");
Data_Get_Struct (tmp, RbCollection, coll);
xmmsv_coll_attribute_remove (coll->real, StringValuePtr (key));
return Qnil;
}
each()
click to toggle source
static VALUE
c_attrs_each (VALUE self)
{
RbCollection *coll = NULL;
xmmsv_t *attributes;
VALUE tmp;
tmp = rb_iv_get (self, "collection");
Data_Get_Struct (tmp, RbCollection, coll);
attributes = xmmsv_coll_attributes_get (coll->real);
xmmsv_dict_foreach (attributes, attr_each,
XINT_TO_POINTER (EACH_PAIR));
return self;
}
Also aliased as: each_pair
each_key()
click to toggle source
static VALUE
c_attrs_each_key (VALUE self)
{
RbCollection *coll = NULL;
xmmsv_t *attributes;
VALUE tmp;
tmp = rb_iv_get (self, "collection");
Data_Get_Struct (tmp, RbCollection, coll);
attributes = xmmsv_coll_attributes_get (coll->real);
xmmsv_dict_foreach (attributes, attr_each,
XINT_TO_POINTER (EACH_KEY));
return self;
}
each_value()
click to toggle source
static VALUE
c_attrs_each_value (VALUE self)
{
RbCollection *coll = NULL;
xmmsv_t *attributes;
VALUE tmp;
tmp = rb_iv_get (self, "collection");
Data_Get_Struct (tmp, RbCollection, coll);
attributes = xmmsv_coll_attributes_get (coll->real);
xmmsv_dict_foreach (attributes, attr_each,
XINT_TO_POINTER (EACH_VALUE));
return self;
}
has_key?(p1)
click to toggle source
static VALUE
c_attrs_has_key (VALUE self, VALUE key)
{
RbCollection *coll = NULL;
VALUE tmp;
int s;
StringValue (key);
tmp = rb_iv_get (self, "collection");
Data_Get_Struct (tmp, RbCollection, coll);
s = xmmsv_coll_attribute_get_string (coll->real, StringValuePtr (key), NULL);
return s ? Qtrue : Qfalse;
}
inspect()
click to toggle source
static VALUE
c_attrs_inspect (VALUE self)
{
return rb_protect_inspect (attrs_inspect, self, 0);
}