Class: ArrPM::V2::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/arr-pm/v2/header.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tagsObject (readonly)

Returns the value of attribute tags.



10
11
12
# File 'lib/arr-pm/v2/header.rb', line 10

def tags
  @tags
end

Instance Method Details

#load(io) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/arr-pm/v2/header.rb', line 12

def load(io)
  headerheader = ArrPM::V2::HeaderHeader.new
  headerheader.load(io)
  headerdata = io.read(headerheader.entries * 16)
  tagdata = io.read(headerheader.bytesize)
  parse(headerdata, headerheader.entries, tagdata)

  # signature headers are padded up to an 8-byte boundar, details here:
  # http://rpm.org/gitweb?p=rpm.git;a=blob;f=lib/signature.c;h=63e59c00f255a538e48cbc8b0cf3b9bd4a4dbd56;hb=HEAD#l204
  # Throw away the pad.
  io.read(tagdata.length % 8)
end

#parse(data, entry_count, tagdata) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/arr-pm/v2/header.rb', line 25

def parse(data, entry_count, tagdata)
  @tags = entry_count.times.collect do |i|
    tag_number, type_number, offset, count = data[i * 16, 16].unpack("NNNN")

    tag = ArrPM::V2::Tag.new(tag_number, type_number)
    tag.parse(tagdata, offset, count)
    tag
  end
  nil
end