Class: Blender3d::PointerType

Inherits:
Object
  • Object
show all
Defined in:
lib/blender-3d/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ PointerType

Returns a new instance of PointerType.



45
46
47
# File 'lib/blender-3d/types.rb', line 45

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



43
44
45
# File 'lib/blender-3d/types.rb', line 43

def type
  @type
end

Instance Method Details

#inspectObject



53
54
55
# File 'lib/blender-3d/types.rb', line 53

def inspect
  "#{@type.inspect}*"
end

#read(reader) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/blender-3d/types.rb', line 57

def read(reader)
  pointer = Pointer.new(reader.read_pointer)

  model = reader.model
  block = model.pointers[pointer]
  if block && block.data.is_a?(String) && !block.type

    if block.count == 1
      size = if @type.is_a?(PointerType)
        model.header.pointer_size
      else
        model.dna_block.data.types.find { |type, _| type == @type.name }.last
      end

      if block.size > size && block.size % size == 0
        block.type = ArrayType.new(@type, block.size / size)
      else
        block.type = @type
      end

    else
      block.type = @type
    end

    block.parse_data(reader.model)
  end

  pointer
end

#to_sObject



49
50
51
# File 'lib/blender-3d/types.rb', line 49

def to_s
  "Pointer(#@type)"
end