Class: RPM::Source

Inherits:
Object
  • Object
show all
Defined in:
ext/rpm/source.c

Direct Known Subclasses

Icon, Patch

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object

Creates a new Source object

Examples:

RPM::Source.new ('http://example.com/hoge/hoge.tar.bz2', 0)
RPM:: Source.new ('http://example.com/fuga/fuga.tar.gz', 1, true)

Parameters:

  • url (String)
  • source (Number)

    number (index)

  • nosource (Boolean)

    Sets the NoSource flag (default false)



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'ext/rpm/source.c', line 30

static VALUE
source_initialize(int argc, VALUE* argv, VALUE src)
{
	switch (argc) {
	case 0: case 1:
		rb_raise(rb_eArgError, "argument too few(2..3)");

	case 2: case 3:
		if (TYPE(argv[0]) != T_STRING) {
			rb_raise(rb_eTypeError, "illegal argument type");
		}

		rb_ivar_set(src, id_full, argv[0]);
		rb_ivar_set(src, id_num, rb_Integer(argv[1]));
		if (argc == 3) {
			rb_ivar_set(src, id_no, RTEST(argv[2]) ? Qtrue : Qfalse);
		} else {
			rb_ivar_set(src, id_no, Qfalse);
		}
		break;

	default:
		rb_raise(rb_eArgError, "argument too many(2..3)");
	}

	return src;
}

Instance Method Details

#filenameString

Returns Source’s filename.

Examples:

src = RPM::Source.new('http://example.com/hoge/hoge.tar.bz2', 0)
src.filename => 'hoge.tar.bz2'

Returns:

  • (String)

    Source’s filename



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'ext/rpm/source.c', line 124

VALUE
rpm_source_get_filename(VALUE src)
{
	VALUE fn = rb_ivar_get(src, id_fn);

	if (NIL_P(fn)) {
		VALUE full = rb_ivar_get(src, id_full);
		const char* p = strrchr(RSTRING_PTR(full), '/');
		if (p == NULL) {
			p = RSTRING_PTR(full);
		} else {
			p++;
		}
		fn = rb_str_new2(p);
		rb_ivar_set(src, id_fn, fn);
	}

	return fn;
}

#fullnameString Also known as: to_s

Returns Source’s fullname.

Examples:

src = RPM::Source.new('http://example.com/hoge/hoge.tar.bz2', 0)
src.fullname => 'http://example.com/hoge/hoge.tar.bz2'

Returns:

  • (String)

    Source’s fullname



112
113
114
115
116
# File 'ext/rpm/source.c', line 112

VALUE
rpm_source_get_fullname(VALUE src)
{
	return rb_ivar_get(src, id_full);
}

#no?Boolean

Returns Whether the NoSource flag is set.

Examples:

src = RPM::Source.new('http://example.com/hoge/hoge.tar.bz2', 0, true)
src.no? => true

Returns:

  • (Boolean)

    Whether the NoSource flag is set



162
163
164
165
166
# File 'ext/rpm/source.c', line 162

VALUE
rpm_source_is_no(VALUE src)
{
	return rb_ivar_get(src, id_no);
}

#numNumber

Returns Source’s index.

Examples:

src = RPM::Source.new ('http://example.com/hoge/hoge.tar.bz2', 0)
src.num => 0

Returns:

  • (Number)

    Source’s index



150
151
152
153
154
# File 'ext/rpm/source.c', line 150

VALUE
rpm_source_get_num(VALUE src)
{
	return rb_ivar_get(src, id_num);
}