Class: OpenUSD::Attribute
- Inherits:
-
Object
- Object
- OpenUSD::Attribute
- Defined in:
- lib/openusd/attribute.rb
Overview
Composed attribute view on a Stage.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prim ⇒ Object
readonly
Returns the value of attribute prim.
Instance Method Summary collapse
-
#connections ⇒ Array<Path>
Strongest authored connections.
-
#get(time: nil) ⇒ Object?
Get the default or a time-sampled value.
-
#initialize(prim, name) ⇒ Attribute
constructor
A new instance of Attribute.
-
#metadata ⇒ MetadataView
Composed, writable metadata.
-
#set(value, time: nil) ⇒ Object
Author a default or time-sampled value in the edit target.
-
#time_samples ⇒ Hash{Float => Object}
Composed samples in time order.
-
#type_name ⇒ String?
Strongest authored USD type name.
Constructor Details
#initialize(prim, name) ⇒ Attribute
Returns a new instance of Attribute.
8 9 10 11 |
# File 'lib/openusd/attribute.rb', line 8 def initialize(prim, name) @prim = prim @name = name.to_s end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/openusd/attribute.rb', line 6 def name @name end |
#prim ⇒ Object (readonly)
Returns the value of attribute prim.
6 7 8 |
# File 'lib/openusd/attribute.rb', line 6 def prim @prim end |
Instance Method Details
#connections ⇒ Array<Path>
Returns strongest authored connections.
43 44 45 |
# File 'lib/openusd/attribute.rb', line 43 def connections opinions.find(&:connections_authored?)&.connections || [] end |
#get(time: nil) ⇒ Object?
Get the default or a time-sampled value.
21 22 23 24 25 26 27 |
# File 'lib/openusd/attribute.rb', line 21 def get(time: nil) return default_value if time.nil? sampled_value(Float(time)) rescue ArgumentError, ::TypeError raise OpenUSD::TypeError, "time must be numeric" end |
#metadata ⇒ MetadataView
Returns composed, writable metadata.
48 49 50 51 |
# File 'lib/openusd/attribute.rb', line 48 def values = opinions.reverse_each.with_object({}) { |opinion, result| result.merge!(opinion.) } MetadataView.new(values, writer: method(:write_metadata)) end |
#set(value, time: nil) ⇒ Object
Author a default or time-sampled value in the edit target.
31 32 33 34 35 |
# File 'lib/openusd/attribute.rb', line 31 def set(value, time: nil) .set(value, time: time) prim.stage.invalidate! value end |
#time_samples ⇒ Hash{Float => Object}
Returns composed samples in time order.
38 39 40 |
# File 'lib/openusd/attribute.rb', line 38 def time_samples opinions.find(&:time_samples_authored?)&.time_samples || {} end |
#type_name ⇒ String?
Returns strongest authored USD type name.
14 15 16 |
# File 'lib/openusd/attribute.rb', line 14 def type_name opinions.first&.type_name end |