Class: OpenUSD::AttributeSpec
- Inherits:
-
Object
- Object
- OpenUSD::AttributeSpec
- Defined in:
- lib/openusd/attribute_spec.rb
Overview
An authored attribute in a Layer.
Constant Summary collapse
- UNAUTHORED =
Sentinel distinguishing an absent default from an authored value block.
Object.new.freeze
- VARIABILITIES =
Valid attribute variability values.
%i[varying uniform].freeze
Instance Attribute Summary collapse
-
#connections ⇒ Object
Returns the value of attribute connections.
-
#custom ⇒ Object
Returns the value of attribute custom.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#time_samples ⇒ Object
Returns the value of attribute time_samples.
-
#type_name ⇒ Object
Returns the value of attribute type_name.
-
#variability ⇒ Object
Returns the value of attribute variability.
Instance Method Summary collapse
-
#clear_default ⇒ Object
Remove the default opinion.
-
#connections_authored? ⇒ Boolean
Whether connections, including an empty list, are authored.
-
#default_authored? ⇒ Boolean
Whether a default opinion, including a value block, is authored.
-
#initialize(name, type_name, default: UNAUTHORED, variability: :varying, custom: false, metadata: {}) ⇒ AttributeSpec
constructor
A new instance of AttributeSpec.
-
#set(value, time: nil) ⇒ Object
Set a default or time-sampled value.
-
#time_samples_authored? ⇒ Boolean
Whether a timeSamples dictionary, including an empty one, is authored.
-
#to_h ⇒ Hash
Semantic representation used for equality.
Constructor Details
#initialize(name, type_name, default: UNAUTHORED, variability: :varying, custom: false, metadata: {}) ⇒ AttributeSpec
Returns a new instance of AttributeSpec.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/openusd/attribute_spec.rb', line 14 def initialize(name, type_name, default: UNAUTHORED, variability: :varying, custom: false, metadata: {}) @name = validate_name(name) @type_name = String(type_name).dup.freeze self.variability = variability @custom = custom == true @metadata = .dup @connections = [] @connections_authored = false @time_samples = {} @time_samples_authored = false @default_authored = false set(default) unless default.equal?(UNAUTHORED) end |
Instance Attribute Details
#connections ⇒ Object
Returns the value of attribute connections.
11 12 13 |
# File 'lib/openusd/attribute_spec.rb', line 11 def connections @connections end |
#custom ⇒ Object
Returns the value of attribute custom.
12 13 14 |
# File 'lib/openusd/attribute_spec.rb', line 12 def custom @custom end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
11 12 13 |
# File 'lib/openusd/attribute_spec.rb', line 11 def default @default end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/openusd/attribute_spec.rb', line 11 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/openusd/attribute_spec.rb', line 11 def name @name end |
#time_samples ⇒ Object
Returns the value of attribute time_samples.
11 12 13 |
# File 'lib/openusd/attribute_spec.rb', line 11 def time_samples @time_samples end |
#type_name ⇒ Object
Returns the value of attribute type_name.
11 12 13 |
# File 'lib/openusd/attribute_spec.rb', line 11 def type_name @type_name end |
#variability ⇒ Object
Returns the value of attribute variability.
11 12 13 |
# File 'lib/openusd/attribute_spec.rb', line 11 def variability @variability end |
Instance Method Details
#clear_default ⇒ Object
Remove the default opinion.
68 69 70 71 72 |
# File 'lib/openusd/attribute_spec.rb', line 68 def clear_default @default = nil @default_authored = false self end |
#connections_authored? ⇒ Boolean
Whether connections, including an empty list, are authored.
53 54 55 |
# File 'lib/openusd/attribute_spec.rb', line 53 def @connections_authored end |
#default_authored? ⇒ Boolean
Whether a default opinion, including a value block, is authored.
43 44 45 |
# File 'lib/openusd/attribute_spec.rb', line 43 def @default_authored end |
#set(value, time: nil) ⇒ Object
Set a default or time-sampled value.
58 59 60 61 62 63 64 65 |
# File 'lib/openusd/attribute_spec.rb', line 58 def set(value, time: nil) normalized = value.nil? ? nil : Types.coerce(type_name, value) return set_time_sample(time, normalized) unless time.nil? @default = normalized @default_authored = true normalized end |
#time_samples_authored? ⇒ Boolean
Whether a timeSamples dictionary, including an empty one, is authored.
48 49 50 |
# File 'lib/openusd/attribute_spec.rb', line 48 def @time_samples_authored end |
#to_h ⇒ Hash
Returns semantic representation used for equality.
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/openusd/attribute_spec.rb', line 91 def to_h { name: name, type_name: type_name, default: default, default_authored: , time_samples: time_samples, time_samples_authored: , variability: variability, custom: custom, connections: connections, connections_authored: , metadata: } end |