Class: Rgltf::Properties::Base
- Inherits:
-
Object
- Object
- Rgltf::Properties::Base
- Defined in:
- lib/rgltf/properties/base.rb
Direct Known Subclasses
Accessor, Accessor::Sparse, Accessor::Sparse::Indices, Accessor::Sparse::Values, Animation, Animation::AnimationSampler, Animation::Channel, Animation::Channel::Target, Asset, Buffer, BufferView, Camera, Camera::Orthographic, Camera::Perspective, Image, Material, Mesh, Node, Rgltf::PbrMetallicRoughness, Rgltf::Primitive, Sampler, Scene, Skin, Texture, TextureInfo
Instance Attribute Summary collapse
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#extras ⇒ Object
readonly
Returns the value of attribute extras.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#owner_type ⇒ Object
readonly
Returns the value of attribute owner_type.
-
#source_json ⇒ Object
readonly
Returns the value of attribute source_json.
Instance Method Summary collapse
- #extension(name) ⇒ Object
-
#initialize(json, document:, index: nil, owner_type: nil) ⇒ Base
constructor
A new instance of Base.
- #nested_properties ⇒ Object
- #parse_extensions! ⇒ Object
Constructor Details
#initialize(json, document:, index: nil, owner_type: nil) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rgltf/properties/base.rb', line 8 def initialize(json, document:, index: nil, owner_type: nil) @document = document @source_json = json @index = index @name = json['name'] @extras = json['extras'] @raw_extensions = json.fetch('extensions', {}) @extensions = {} @owner_type = owner_type end |
Instance Attribute Details
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
6 7 8 |
# File 'lib/rgltf/properties/base.rb', line 6 def extensions @extensions end |
#extras ⇒ Object (readonly)
Returns the value of attribute extras.
6 7 8 |
# File 'lib/rgltf/properties/base.rb', line 6 def extras @extras end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/rgltf/properties/base.rb', line 6 def index @index end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rgltf/properties/base.rb', line 6 def name @name end |
#owner_type ⇒ Object (readonly)
Returns the value of attribute owner_type.
6 7 8 |
# File 'lib/rgltf/properties/base.rb', line 6 def owner_type @owner_type end |
#source_json ⇒ Object (readonly)
Returns the value of attribute source_json.
6 7 8 |
# File 'lib/rgltf/properties/base.rb', line 6 def source_json @source_json end |
Instance Method Details
#extension(name) ⇒ Object
19 20 21 |
# File 'lib/rgltf/properties/base.rb', line 19 def extension(name) extensions[name] end |
#nested_properties ⇒ Object
40 41 42 |
# File 'lib/rgltf/properties/base.rb', line 40 def nested_properties [] end |
#parse_extensions! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rgltf/properties/base.rb', line 23 def parse_extensions! return self if @extensions_parsed @extensions = @raw_extensions.each_with_object({}) do |(name, value), parsed| parsed[name] = @document.extension_registry.parse( name, value, on: @owner_type, owner: self, doc: @document ) end.freeze @extensions_parsed = true nested_properties.each(&:parse_extensions!) self end |