Class: KeyedArchive
- Inherits:
-
Object
- Object
- KeyedArchive
- Defined in:
- lib/keyed_archive.rb,
lib/keyed_archive/version.rb,
lib/keyed_archive/unpacked_objects.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#archiver ⇒ Object
Returns the value of attribute archiver.
-
#objects ⇒ Object
Returns the value of attribute objects.
-
#top ⇒ Object
Returns the value of attribute top.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(file) ⇒ KeyedArchive
constructor
A new instance of KeyedArchive.
- #unpacked_objects ⇒ Object
Constructor Details
#initialize(file) ⇒ KeyedArchive
Returns a new instance of KeyedArchive.
9 10 11 12 13 14 15 16 17 |
# File 'lib/keyed_archive.rb', line 9 def initialize(file) plist = CFPropertyList::List.new(:file => file) data = CFPropertyList.native_types(plist.value) @archiver = data['$archiver'] @objects = data['$objects'] @top = data['$top'] @version = data['$version'] end |
Instance Attribute Details
#archiver ⇒ Object
Returns the value of attribute archiver.
7 8 9 |
# File 'lib/keyed_archive.rb', line 7 def archiver @archiver end |
#objects ⇒ Object
Returns the value of attribute objects.
7 8 9 |
# File 'lib/keyed_archive.rb', line 7 def objects @objects end |
#top ⇒ Object
Returns the value of attribute top.
7 8 9 |
# File 'lib/keyed_archive.rb', line 7 def top @top end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/keyed_archive.rb', line 7 def version @version end |
Instance Method Details
#unpacked_objects ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/keyed_archive/unpacked_objects.rb', line 2 def unpacked_objects objects = @objects.clone unpacked_objects = [] objects.each_with_index do |object, index| if object.is_a? Hash object.each_pair do |key, value| if value.is_a? Hash uid = value['CF$UID'] if uid new_object = {} new_object[key] = @objects[uid] objects.push new_object unpacked_objects.delete_at(index - 1) end else new_object = {} new_object[key] = value unpacked_objects.push new_object end end else unpacked_objects.push object end end return unpacked_objects end |