Class: OpenUSD::Attribute

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

Overview

Composed attribute view on a Stage.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#primObject (readonly)

Returns the value of attribute prim.



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

def prim
  @prim
end

Instance Method Details

#connectionsArray<Path>

Returns strongest authored connections.

Returns:

  • (Array<Path>)

    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.

Parameters:

  • time (Numeric, nil) (defaults to: nil)

Returns:

  • (Object, nil)


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

#metadataMetadataView

Returns composed, writable metadata.

Returns:



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.

Returns:

  • (Object)

    input value



31
32
33
34
35
# File 'lib/openusd/attribute.rb', line 31

def set(value, time: nil)
  authored_spec.set(value, time: time)
  prim.stage.invalidate!
  value
end

#time_samplesHash{Float => Object}

Returns composed samples in time order.

Returns:

  • (Hash{Float => Object})

    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_nameString?

Returns strongest authored USD type name.

Returns:

  • (String, nil)

    strongest authored USD type name



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

def type_name
  opinions.first&.type_name
end