Class: OpenUSD::Relationship

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

Overview

Composed relationship view on a Stage.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prim, name) ⇒ Relationship

Returns a new instance of Relationship.



8
9
10
11
# File 'lib/openusd/relationship.rb', line 8

def initialize(prim, name)
  @prim = prim
  @name = name.to_s
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/openusd/relationship.rb', line 6

def name
  @name
end

#primObject (readonly)

Returns the value of attribute prim.



6
7
8
# File 'lib/openusd/relationship.rb', line 6

def prim
  @prim
end

Instance Method Details

#add_target(path) ⇒ Relationship

Add one target in the edit target.

Returns:



20
21
22
23
24
# File 'lib/openusd/relationship.rb', line 20

def add_target(path)
  authored_spec.add_target(path)
  prim.stage.invalidate!
  self
end

#metadataMetadataView

Returns composed, writable metadata.

Returns:



35
36
37
38
# File 'lib/openusd/relationship.rb', line 35

def 
  values = opinions.reverse_each.with_object({}) { |opinion, result| result.merge!(opinion.) }
  MetadataView.new(values, writer: method(:write_metadata))
end

#set_targets(paths) ⇒ Relationship

Replace targets in the edit target.

Returns:



28
29
30
31
32
# File 'lib/openusd/relationship.rb', line 28

def set_targets(paths)
  authored_spec.targets = paths
  prim.stage.invalidate!
  self
end

#targetsArray<Path>

Returns strongest authored targets.

Returns:

  • (Array<Path>)

    strongest authored targets



14
15
16
# File 'lib/openusd/relationship.rb', line 14

def targets
  opinions.find(&:targets_authored?)&.targets || []
end