Class: OpenUSD::Format::Usda::Writer
- Inherits:
-
Object
- Object
- OpenUSD::Format::Usda::Writer
- 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
-
.write(layer, path) ⇒ String
Serialize a layer to a filesystem path.
Instance Method Summary collapse
-
#write_to_string(layer) ⇒ String
Serialize a layer to USDA text.
Class Method Details
.write(layer, path) ⇒ String
Serialize a layer to a filesystem 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.
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 |