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 =
"1.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(opts = {}) ⇒ KeyedArchive
constructor
Take the same sort of arguments as CFPropertyList :file => filename to load :data => variable with the data to load directly.
-
#unpacked_top ⇒ Object
Loops through the entries within ‘$top’ to replace any values that are pointers to objects.
Constructor Details
#initialize(opts = {}) ⇒ KeyedArchive
Take the same sort of arguments as CFPropertyList :file => filename to load :data => variable with the data to load directly
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/keyed_archive.rb', line 13 def initialize(opts={}) blob = opts[:data] filename = opts[:file] plist = CFPropertyList::List.new(:file => filename) unless filename.nil? or !File.exist?(filename) plist = CFPropertyList::List.new(:data => blob) unless blob.nil? or blob.length < 1 if !plist.nil? data = CFPropertyList.native_types(plist.value) @archiver = data['$archiver'] @objects = data['$objects'] @top = data['$top'] @version = data['$version'] else raise "Plist not created" end 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_top ⇒ Object
Loops through the entries within ‘$top’ to replace any values that are pointers to objects.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/keyed_archive/unpacked_objects.rb', line 5 def unpacked_top # Create the return value unpacked_top = Hash.new # Loop over each pair in the '$top' hash # to recursively replace the values @top.each_pair do |key, value| unpacked_top[key] = recursive_replace(value, -1, []) end # Politely return, our job is done return unpacked_top end |