Class: RPM::Version
- Inherits:
-
Object
- Object
- RPM::Version
- Includes:
- Comparable
- Defined in:
- ext/rpm/version.c
Instance Method Summary (collapse)
-
- (Number) <=>
Comparison between versions.
-
- (Number) e
Access the epoch component.
-
- (String) hash
Hash based on the version content.
- - (Object) initialize constructor
-
- (String) inspect
Inspect the version object.
-
- (Boolean) newer?
True if the version is newer than other.
-
- (Boolean) older?
True if the version is older than other.
-
- (String) r
Access the release component.
-
- (String) to_s
String representation in the form "v-r".
-
- (String) to_vre
String representation in the form "e:v-r".
-
- (String) v
Access the version component.
Constructor Details
- (Version) new(vr, e = nil) - (Version) new(v, r, e = nil)
|
# File 'ext/rpm/version.c'
static VALUE
version_initialize(int argc, VALUE* argv, VALUE ver)
{
VALUE v = Qnil;
VALUE r = Qnil;
VALUE e = Qnil;
switch (argc) {
case 0:
rb_raise(rb_eArgError, "argument too few(1..3)");
case 1:
if (TYPE(argv[0]) != T_STRING) {
rb_raise(rb_eTypeError, "illegal argument type");
}
|
Instance Method Details
- (Number) <=>
Comparison between versions
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_cmp(VALUE ver, VALUE other)
{
VALUE ve,oe;
VALUE vr,or;
VALUE vv,ov;
int sense = 0;
if (rb_obj_is_kind_of(other, rpm_cVersion) != Qtrue) {
rb_raise(rb_eTypeError, "illegal argument type");
}
|
- (Number) e
Access the epoch component
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_get_e(VALUE ver)
{
return rb_ivar_get(ver, id_e);
}
|
- (String) hash
Hash based on the version content
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_hash(VALUE ver)
{
long h;
VALUE v, r, e;
v = rb_ivar_get(ver, id_v);
r = rb_ivar_get(ver, id_r);
e = rb_ivar_get(ver, id_e);
h = NIL_P(e) ? 0 : NUM2INT(e);
h = (h << 1) ^ NUM2LONG(rb_hash(r));
h = (h << 1) ^ NUM2LONG(rb_hash(v));
return LONG2FIX(h);
}
|
- (String) inspect
Inspect the version object
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_inspect(VALUE ver)
{
char buf[BUFSIZ];
VALUE v, r, e;
v = rb_ivar_get(ver, id_v);
r = rb_ivar_get(ver, id_r);
e = rb_ivar_get(ver, id_e);
if (!NIL_P(e)) {
snprintf(buf, BUFSIZ, "#<RPM::Version v=%s, r=%s, e=%ld>", RSTRING_PTR(rb_inspect(v)), RSTRING_PTR(rb_inspect(r)), (long) NUM2INT(e));
}
|
- (Boolean) newer?
True if the version is newer than other
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_is_newer(VALUE ver, VALUE other)
{
return (NUM2INT(rpm_version_cmp(ver, other)) > 0) ? Qtrue : Qfalse;
}
|
- (Boolean) older?
True if the version is older than other
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_is_older(VALUE ver, VALUE other)
{
return rpm_version_is_newer(ver, other) ? Qfalse : Qtrue;
}
|
- (String) r
Access the release component
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_get_r(VALUE ver)
{
return rb_ivar_get(ver, id_r);
}
|
- (String) to_s
The epoch is not included
String representation in the form "v-r"
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_to_s(VALUE ver)
{
char buf[BUFSIZ];
char *p = buf;
VALUE v, r;
v = rb_ivar_get(ver, id_v);
r = rb_ivar_get(ver, id_r);
strcpy(p, RSTRING_PTR(v));
if (!NIL_P(r)) {
strcat(p, "-");
strcat(p, RSTRING_PTR(r));
}
|
- (String) to_vre
The epoch is included
String representation in the form "e:v-r"
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_to_vre(VALUE ver)
{
char buf[BUFSIZ];
char *p = buf;
VALUE v, r, e;
v = rb_ivar_get(ver, id_v);
r = rb_ivar_get(ver, id_r);
e = rb_ivar_get(ver, id_e);
if (!NIL_P(e)) {
snprintf(buf,BUFSIZ,"%ld:", (long) NUM2INT(e));
p += strlen(buf);
}
|
- (String) v
Access the version component
|
# File 'ext/rpm/version.c'
VALUE
rpm_version_get_v(VALUE ver)
{
return rb_ivar_get(ver, id_v);
}
|