Class: KeyedArchive

Inherits:
Object
  • Object
show all
Defined in:
lib/imsg-grep/apple/keyed_archive.rb

Defined Under Namespace

Classes: BinaryString

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ KeyedArchive

Returns a new instance of KeyedArchive.



21
22
23
24
25
26
# File 'lib/imsg-grep/apple/keyed_archive.rb', line 21

def initialize(data)
  return unless data
  return if data[0, 4] == "\x08\x08\x11\x00" # DigitalTouchBalloonProvider row; another format, ignore
  raise "no bplist: #{data}" unless data.start_with?("bplist")
  @data = BPList.parse data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/imsg-grep/apple/keyed_archive.rb', line 11

def data
  @data
end

Class Method Details

.jsonObject



19
# File 'lib/imsg-grep/apple/keyed_archive.rb', line 19

def self.json(...) = new(...).json

.unarchiveObject



18
# File 'lib/imsg-grep/apple/keyed_archive.rb', line 18

def self.unarchive(...) = new(...).unarchive

Instance Method Details

#jsonObject



36
# File 'lib/imsg-grep/apple/keyed_archive.rb', line 36

def json = unarchive&.to_json

#unarchiveObject



28
29
30
31
32
33
34
# File 'lib/imsg-grep/apple/keyed_archive.rb', line 28

def unarchive
  return unless @data # initialize failed
  top  = @data["$top"] or raise "no top"
  root = top["root"] or raise "no root"
  objs = @data["$objects"] or raise "no objects"
  decode_objects dereference_uids(root, objs)
end