Module | Plist::Emit |
In: |
lib/facter/util/plist/generator.rb
|
You can dump an object to a plist in one of two ways:
The following Ruby classes are converted into native plist types:
Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false
For detailed usage instructions, refer to USAGE and the methods documented below.
The following Ruby classes are converted into native plist types:
Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time
Write us (via RubyForge) if you think another class can be coerced safely into one of the expected plist classes.
IO and StringIO objects are encoded and placed in <data> elements; other objects are Marshal.dump‘ed unless they implement to_plist_node.
The envelope parameters dictates whether or not the resultant plist fragment is wrapped in the normal XML/plist header and footer. Set it to false if you only want the fragment.
# File lib/facter/util/plist/generator.rb, line 43 43: def self.dump(obj, envelope = true) 44: output = plist_node(obj) 45: 46: output = wrap(output) if envelope 47: 48: return output 49: end
Writes the serialized object‘s plist to the specified filename.
# File lib/facter/util/plist/generator.rb, line 52 52: def self.save_plist(obj, filename) 53: File.open(filename, 'wb') do |f| 54: f.write(obj.to_plist) 55: end 56: end
Helper method for injecting into classes. Calls Plist::Emit.save_plist with self.
# File lib/facter/util/plist/generator.rb, line 31 31: def save_plist(filename) 32: Plist::Emit.save_plist(self, filename) 33: end
Helper method for injecting into classes. Calls Plist::Emit.dump with self.
# File lib/facter/util/plist/generator.rb, line 26 26: def to_plist(envelope = true) 27: return Plist::Emit.dump(self, envelope) 28: end