Class: BinaryPList::Parser::ObjectReaders::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/binary_plist/parser/object_readers/array.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BinaryPList::Parser::ObjectReaders::Base

Class Method Details

.reads?(marker) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/binary_plist/parser/object_readers/array.rb', line 8

def self.reads?(marker)
  return true if (0b1010_0000..0b1010_1111).include?(marker)

  false
end

Instance Method Details

#array_lengthObject



30
31
32
33
34
35
36
# File 'lib/binary_plist/parser/object_readers/array.rb', line 30

def array_length
  if @marker == 0b1010_1111
    Int.new(nil, io, offset_table, trailer).read(io.getbyte)
  else
    @marker - 0b1010_0000
  end
end

#object_refsObject



24
25
26
27
28
# File 'lib/binary_plist/parser/object_readers/array.rb', line 24

def object_refs
  array_length.times.map do
    read_objref
  end
end

#read(marker) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/binary_plist/parser/object_readers/array.rb', line 14

def read(marker)
  raise UnsupportedMarkerError, marker unless self.class.reads?(marker)

  @marker = marker

  object_refs.map do |object_ref|
    object(object_ref)
  end
end