Class: MagicaVoxel::File

Inherits:
Object
  • Object
show all
Defined in:
lib/magica_voxel/file.rb

Overview

The MagicaVoxel file

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ File

Returns a new instance of File.

Parameters:

  • path (String)

    the .vox file path

Since:

  • 0.1.0



16
17
18
19
20
21
22
23
# File 'lib/magica_voxel/file.rb', line 16

def initialize(path)
  @path = path
  ::File.open(@path, mode: 'rb') do |io|
    @format = io.read(4).strip
    @version = io.read(4).unpack1('L')
    @root = Chunk.read(io).first
  end
end

Instance Attribute Details

#formatObject (readonly)

Since:

  • 0.1.0



11
12
13
# File 'lib/magica_voxel/file.rb', line 11

def format
  @format
end

#pathObject (readonly)

Since:

  • 0.1.0



11
12
13
# File 'lib/magica_voxel/file.rb', line 11

def path
  @path
end

#rootObject (readonly)

Since:

  • 0.1.0



11
12
13
# File 'lib/magica_voxel/file.rb', line 11

def root
  @root
end

#versionObject (readonly)

Since:

  • 0.1.0



11
12
13
# File 'lib/magica_voxel/file.rb', line 11

def version
  @version
end

Instance Method Details

#valid?TrueClass|FalseClass

Returns is valid MagicaVoxel file.

Returns:

  • (TrueClass|FalseClass)

    is valid MagicaVoxel file

Since:

  • 0.1.0



28
29
30
# File 'lib/magica_voxel/file.rb', line 28

def valid?
  format == 'VOX'
end