Class: Nanaimo::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/nanaimo/writer.rb,
lib/nanaimo/writer/xml.rb,
lib/nanaimo/writer/pbxproj.rb

Overview

Transforms native ruby objects or Plist objects into their ASCII Plist string representation.

Direct Known Subclasses

PBXProjWriter, XMLWriter

Defined Under Namespace

Classes: PBXProjWriter, UnsupportedPlistTypeError, XMLWriter

Constant Summary collapse

UTF8 =

The magic comment that denotes a UTF8-encoded plist.

"// !$*UTF8*$!\n".freeze

Instance Method Summary collapse

Constructor Details

#initialize(plist, pretty: true, output: ::String.new, strict: true) ⇒ Writer

Returns a new instance of Writer.

Parameters:

  • plist (Plist, String, Hash, Array)

    The plist obejct to write

  • pretty (Boolean) (defaults to: true)

    Whether to serialize annotations and add spaces and newlines to make output more legible

  • output (#<<) (defaults to: ::String.new)

    The output stream to write the plist to



33
34
35
36
37
38
39
40
# File 'lib/nanaimo/writer.rb', line 33

def initialize(plist, pretty: true, output: ::String.new, strict: true)
  @plist = plist
  @pretty = pretty
  @output = output
  @indent = 0
  @newlines = true
  @strict = strict
end

Instance Method Details

#writeObject

Writes the plist to the given output.



44
45
46
47
48
# File 'lib/nanaimo/writer.rb', line 44

def write
  write_utf8
  write_object(@plist.root_object)
  write_newline
end