Class: Assimp::ImportSource
- Inherits:
-
Object
- Object
- Assimp::ImportSource
- Defined in:
- lib/assimp/import_source.rb
Constant Summary collapse
- MAX_MEMORY_SIZE =
(2**32) - 1
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
-
#hint ⇒ Object
readonly
Returns the value of attribute hint.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(source, hint:) ⇒ ImportSource
constructor
A new instance of ImportSource.
- #path? ⇒ Boolean
Constructor Details
#initialize(source, hint:) ⇒ ImportSource
Returns a new instance of ImportSource.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/assimp/import_source.rb', line 9 def initialize(source, hint:) @hint = normalize_hint(hint) if path_source?(source) @path = source.respond_to?(:to_path) ? source.to_path : source else @bytes = read_bytes(source) raise ArgumentError, "hint is required for memory imports" unless @hint raise ArgumentError, "memory source cannot be empty" if @bytes.empty? raise ArgumentError, "memory import exceeds Assimp's 32-bit size limit" if @bytes.bytesize > MAX_MEMORY_SIZE end end |
Instance Attribute Details
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
7 8 9 |
# File 'lib/assimp/import_source.rb', line 7 def bytes @bytes end |
#hint ⇒ Object (readonly)
Returns the value of attribute hint.
7 8 9 |
# File 'lib/assimp/import_source.rb', line 7 def hint @hint end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/assimp/import_source.rb', line 7 def path @path end |
Instance Method Details
#path? ⇒ Boolean
21 22 23 |
# File 'lib/assimp/import_source.rb', line 21 def path? !path.nil? end |