Class: OpenUSD::RelationshipSpec
- Inherits:
-
Object
- Object
- OpenUSD::RelationshipSpec
- Defined in:
- lib/openusd/relationship_spec.rb
Overview
An authored relationship in a Layer.
Constant Summary collapse
- UNAUTHORED =
Sentinel distinguishing no target opinion from an authored empty list.
Object.new.freeze
Instance Attribute Summary collapse
-
#custom ⇒ Object
Returns the value of attribute custom.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#targets ⇒ Object
Returns the value of attribute targets.
Instance Method Summary collapse
-
#add_target(path) ⇒ Path
Add a target unless it is already present.
-
#initialize(name, targets: UNAUTHORED, custom: false, metadata: {}) ⇒ RelationshipSpec
constructor
A new instance of RelationshipSpec.
-
#targets_authored? ⇒ Boolean
Whether targets, including an empty list, are authored.
-
#to_h ⇒ Hash
Semantic representation used for equality.
Constructor Details
#initialize(name, targets: UNAUTHORED, custom: false, metadata: {}) ⇒ RelationshipSpec
Returns a new instance of RelationshipSpec.
12 13 14 15 16 17 18 19 |
# File 'lib/openusd/relationship_spec.rb', line 12 def initialize(name, targets: UNAUTHORED, custom: false, metadata: {}) @name = validate_name(name) @custom = custom == true @metadata = .dup @targets = [] @targets_authored = false self.targets = targets unless targets.equal?(UNAUTHORED) end |
Instance Attribute Details
#custom ⇒ Object
Returns the value of attribute custom.
10 11 12 |
# File 'lib/openusd/relationship_spec.rb', line 10 def custom @custom end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/openusd/relationship_spec.rb', line 9 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/openusd/relationship_spec.rb', line 9 def name @name end |
#targets ⇒ Object
Returns the value of attribute targets.
9 10 11 |
# File 'lib/openusd/relationship_spec.rb', line 9 def targets @targets end |
Instance Method Details
#add_target(path) ⇒ Path
Add a target unless it is already present.
33 34 35 36 37 38 |
# File 'lib/openusd/relationship_spec.rb', line 33 def add_target(path) target = Path.parse(path) @targets << target unless @targets.include?(target) @targets_authored = true target end |
#targets_authored? ⇒ Boolean
Whether targets, including an empty list, are authored.
27 28 29 |
# File 'lib/openusd/relationship_spec.rb', line 27 def @targets_authored end |
#to_h ⇒ Hash
Returns semantic representation used for equality.
41 42 43 44 45 46 |
# File 'lib/openusd/relationship_spec.rb', line 41 def to_h { name: name, targets: targets, targets_authored: , custom: custom, metadata: } end |