Class: OpenUSD::Schema::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/openusd/schema/base.rb

Overview

Base for typed convenience wrappers around Stage prims.

Direct Known Subclasses

Camera, Material, Mesh, Scope, Xform

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prim) ⇒ Base

Returns a new instance of Base.



35
36
37
# File 'lib/openusd/schema/base.rb', line 35

def initialize(prim)
  @prim = prim
end

Class Attribute Details

.type_nameObject (readonly)

Returns the value of attribute type_name.



9
10
11
# File 'lib/openusd/schema/base.rb', line 9

def type_name
  @type_name
end

Instance Attribute Details

#primObject (readonly)

Returns the value of attribute prim.



33
34
35
# File 'lib/openusd/schema/base.rb', line 33

def prim
  @prim
end

Class Method Details

.define(stage, path) ⇒ Base

Define and wrap a prim.

Returns:



19
20
21
# File 'lib/openusd/schema/base.rb', line 19

def define(stage, path)
  new(stage.define_prim(path, type_name))
end

.get(stage, path) ⇒ Base?

Wrap a prim only when its type matches.

Returns:



25
26
27
28
29
30
# File 'lib/openusd/schema/base.rb', line 25

def get(stage, path)
  prim = stage.prim_at(path)
  return unless prim&.type_name == type_name

  new(prim)
end

.schema_type(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Declare the prim type represented by a wrapper.



13
14
15
# File 'lib/openusd/schema/base.rb', line 13

def schema_type(name)
  @type_name = name.freeze
end

Instance Method Details

#pathPath

Returns wrapped prim path.

Returns:

  • (Path)

    wrapped prim path



45
46
47
# File 'lib/openusd/schema/base.rb', line 45

def path
  prim.path
end

#stageStage

Returns owning stage.

Returns:

  • (Stage)

    owning stage



40
41
42
# File 'lib/openusd/schema/base.rb', line 40

def stage
  prim.stage
end