Class: OpenUSD::Format::Usda::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/openusd/format/usda/writer.rb

Overview

Deterministic USDA serializer.

Constant Summary collapse

INDENT =

Indentation used for nested USDA constructs.

" " * 4

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.write(layer, path) ⇒ String

Serialize a layer to a filesystem path.

Returns:

  • (String)

    destination path



14
15
16
17
# File 'lib/openusd/format/usda/writer.rb', line 14

def write(layer, path)
  File.binwrite(path, new.write_to_string(layer))
  path
end

Instance Method Details

#write_to_string(layer) ⇒ String

Serialize a layer to USDA text.

Returns:

  • (String)


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/openusd/format/usda/writer.rb', line 22

def write_to_string(layer)
  @lines = ["#usda 1.0"]
  (layer., 0, layer_comment: true) unless layer..empty?
  layer.root_prims.each do |prim|
    line
    write_prim(prim, 0)
  end
  "#{@lines.join("\n")}\n"
ensure
  @lines = nil
end