class Blender3d::FileBlock

Attributes

code[RW]
count[RW]
data[RW]
pointer[RW]
size[RW]
type[RW]
type_index[RW]

Public Class Methods

new(reader = nil) click to toggle source
# File lib/blender-3d/file_block.rb, line 7
def initialize(reader = nil)
  deserialize(reader) if reader
end

Public Instance Methods

deserialize(reader) click to toggle source
# File lib/blender-3d/file_block.rb, line 11
def deserialize(reader)
  Reader.new(reader, self).read
end
parse_data(model) click to toggle source
# File lib/blender-3d/file_block.rb, line 15
def parse_data(model)
  file = StringIO.new(data)
  reader = model.create_reader(file)
  self.data = count.times.map { self.type.read(reader) }
end
to_xml() click to toggle source
# File lib/blender-3d/file_block.rb, line 21
def to_xml
  REXML::Element.new(self.class.basename).tap do |e|
    e.add_attribute 'code', code
    e.add_attribute 'pointer', pointer.inspect
    e.add_attribute 'size', size.to_s
    e.add_attribute 'type_index', type_index.to_s
    e.add_element data_to_xml
  end
end

Private Instance Methods

data_to_xml() click to toggle source
# File lib/blender-3d/file_block.rb, line 31
        def data_to_xml
  content = value_to_xml(@data)
  return content if content.is_a?(REXML::Element)

  REXML::Element.new('data').tap do |e|
    e.add_attribute 'count', count.to_s
    e.add_text content
  end
end