Class: BinaryPList::Trailer
- Inherits:
-
Struct
- Object
- Struct
- BinaryPList::Trailer
- Defined in:
- lib/binary_plist/trailer.rb
Instance Attribute Summary collapse
-
#num_objects ⇒ Object
Returns the value of attribute num_objects.
-
#object_ref_size ⇒ Object
Returns the value of attribute object_ref_size.
-
#offset_int_size ⇒ Object
Returns the value of attribute offset_int_size.
-
#offset_table_offset ⇒ Object
Returns the value of attribute offset_table_offset.
-
#sort_version ⇒ Object
Returns the value of attribute sort_version.
-
#top_object ⇒ Object
Returns the value of attribute top_object.
Class Method Summary collapse
Instance Method Summary collapse
- #check_object_offset!(offset) ⇒ Object
- #check_object_reference!(ref) ⇒ Object
- #object_table_range ⇒ Object
- #offset_table_range ⇒ Object
- #pack ⇒ Object
Instance Attribute Details
#num_objects ⇒ Object
Returns the value of attribute num_objects
14 15 16 |
# File 'lib/binary_plist/trailer.rb', line 14 def num_objects @num_objects end |
#object_ref_size ⇒ Object
Returns the value of attribute object_ref_size
14 15 16 |
# File 'lib/binary_plist/trailer.rb', line 14 def object_ref_size @object_ref_size end |
#offset_int_size ⇒ Object
Returns the value of attribute offset_int_size
14 15 16 |
# File 'lib/binary_plist/trailer.rb', line 14 def offset_int_size @offset_int_size end |
#offset_table_offset ⇒ Object
Returns the value of attribute offset_table_offset
14 15 16 |
# File 'lib/binary_plist/trailer.rb', line 14 def offset_table_offset @offset_table_offset end |
#sort_version ⇒ Object
Returns the value of attribute sort_version
14 15 16 |
# File 'lib/binary_plist/trailer.rb', line 14 def sort_version @sort_version end |
#top_object ⇒ Object
Returns the value of attribute top_object
14 15 16 |
# File 'lib/binary_plist/trailer.rb', line 14 def top_object @top_object end |
Class Method Details
.load(io) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/binary_plist/trailer.rb', line 20 def self.load(io) bytes = io.is_a?(String) ? bytes : io.read(32) sort_version, offset_int_size, object_ref_size, num_objects, top_object, offset_table_offset = bytes.unpack("@5 CCC Q>3") Trailer.new(sort_version, offset_int_size, object_ref_size, num_objects, top_object, offset_table_offset) end |
Instance Method Details
#check_object_offset!(offset) ⇒ Object
40 41 42 43 44 |
# File 'lib/binary_plist/trailer.rb', line 40 def check_object_offset!(offset) return if object_table_range.include?(offset) raise OffsetOutOfRangeError, offset: offset, range: object_table_range end |
#check_object_reference!(ref) ⇒ Object
46 47 48 49 50 |
# File 'lib/binary_plist/trailer.rb', line 46 def check_object_reference!(ref) return unless num_objects < ref raise ObjectOutOfRangeError, num: num, max: trailer.num_objects end |
#object_table_range ⇒ Object
52 53 54 |
# File 'lib/binary_plist/trailer.rb', line 52 def object_table_range (8...offset_table_offset) end |
#offset_table_range ⇒ Object
56 57 58 |
# File 'lib/binary_plist/trailer.rb', line 56 def offset_table_range (offset_table_offset..offset_table_offset + num_objects * offset_int_size) end |
#pack ⇒ Object
35 36 37 38 |
# File 'lib/binary_plist/trailer.rb', line 35 def pack [0, 0, 0, 0, 0, sort_version, offset_int_size, object_ref_size, num_objects, top_object, offset_table_offset].pack("C8Q>3") end |