Class: Assimp::ImportSource

Inherits:
Object
  • Object
show all
Defined in:
lib/assimp/import_source.rb

Constant Summary collapse

MAX_MEMORY_SIZE =
(2**32) - 1

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bytesObject (readonly)

Returns the value of attribute bytes.



7
8
9
# File 'lib/assimp/import_source.rb', line 7

def bytes
  @bytes
end

#hintObject (readonly)

Returns the value of attribute hint.



7
8
9
# File 'lib/assimp/import_source.rb', line 7

def hint
  @hint
end

#pathObject (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

Returns:

  • (Boolean)


21
22
23
# File 'lib/assimp/import_source.rb', line 21

def path?
  !path.nil?
end