Module Plist::Emit
In: lib/facter/util/plist/generator.rb

Create a plist

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
  • Array and Hash are both recursive; their elements will be converted into plist nodes inside the <array> and <dict> containers (respectively).
  • IO (and its descendants) and StringIO objects are read from and their contents placed in a <data> element.
  • User classes may implement to_plist_node to dictate how they should be serialized; otherwise the object will be passed to Marshal.dump and the result placed in a <data> element.

For detailed usage instructions, refer to USAGE and the methods documented below.

Methods

Public Class methods

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.

Writes the serialized object‘s plist to the specified filename.

Public Instance methods

Helper method for injecting into classes. Calls Plist::Emit.save_plist with self.

Helper method for injecting into classes. Calls Plist::Emit.dump with self.

[Validate]