Class: Rupert::RPM::Entry
- Inherits:
-
Object
- Object
- Rupert::RPM::Entry
- Defined in:
- lib/rupert/rpm/entry.rb
Instance Attribute Summary collapse
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
-
#initialize(tag, type, offset, count) ⇒ Entry
constructor
Initializes a new index entry.
-
#resolve(store) ⇒ Object
Fetches referenced data from a store.
Constructor Details
#initialize(tag, type, offset, count) ⇒ Entry
Initializes a new index entry.
10 11 12 |
# File 'lib/rupert/rpm/entry.rb', line 10 def initialize(tag, type, offset, count) @tag, @type, @offset, @count = tag, type, offset, count end |
Instance Attribute Details
#tag ⇒ Object
Returns the value of attribute tag.
14 15 16 |
# File 'lib/rupert/rpm/entry.rb', line 14 def tag @tag end |
Instance Method Details
#resolve(store) ⇒ Object
Fetches referenced data from a store.
An entry contains only information about a piece of data, but not the actual data. In essence, it behaves more or less like a pointer, which contains the address at which data is available.
This method behaves exactly like pointer dereference, i.e. it returns the actual data at the address held by the entry itself. In addition, data is not returned in raw form; instead, it is returned in the format declared in the entry itself. The available RPM formats are the following:
-
NULL
-
CHAR
-
INT8
-
INT16
-
INT32
-
INT64 (not supported yet even in rpmlib?)
-
STRING
-
BIN
-
STRING_ARRAY
-
I18NSTRING
which are in turn mapped in Ruby with:
-
nil
-
(
Array
of)String
of length 1 -
(
Array
of)Fixnum
-
(
Array
of)Fixnum
-
(
Array
of)Fixnum
-
(
Array
of)Fixnum
/Bignum
-
String
of arbitrary length -
String
of arbitrary length, 8-bit ASCII encoded -
Array
ofString
-
Array
ofString
NOTE: The store is sought to retrieve data. Do not make any assumptions on IO’s pointer state after method call. If you need to perform subsequent operations on the IO that require a particular cursor position, seek the IO to wanted position before performing the operation.
61 62 63 64 |
# File 'lib/rupert/rpm/entry.rb', line 61 def resolve(store) store.seek(@offset, IO::SEEK_SET) read_and_convert(@type, store) end |