Class: Table

Inherits:
Object show all
Defined in:
lib/rmxp_extractor/ron.rb,
lib/rmxp_extractor/classnames.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



106
107
108
# File 'lib/rmxp_extractor/classnames.rb', line 106

def elements
  @elements
end

#num_of_dimensionsObject

Returns the value of attribute num_of_dimensions.



106
107
108
# File 'lib/rmxp_extractor/classnames.rb', line 106

def num_of_dimensions
  @num_of_dimensions
end

#num_of_elementsObject

Returns the value of attribute num_of_elements.



106
107
108
# File 'lib/rmxp_extractor/classnames.rb', line 106

def num_of_elements
  @num_of_elements
end

#xsizeObject

Returns the value of attribute xsize.



106
107
108
# File 'lib/rmxp_extractor/classnames.rb', line 106

def xsize
  @xsize
end

#ysizeObject

Returns the value of attribute ysize.



106
107
108
# File 'lib/rmxp_extractor/classnames.rb', line 106

def ysize
  @ysize
end

#zsizeObject

Returns the value of attribute zsize.



106
107
108
# File 'lib/rmxp_extractor/classnames.rb', line 106

def zsize
  @zsize
end

Class Method Details

._load(data) ⇒ Object



112
113
114
115
116
# File 'lib/rmxp_extractor/classnames.rb', line 112

def self._load(data)
  obj = self.new
  obj.num_of_dimensions, obj.xsize, obj.ysize, obj.zsize, obj.num_of_elements, *obj.elements = *data.unpack("VVVVVv*")
  obj
end

Instance Method Details

#_dump(limit) ⇒ Object



108
109
110
# File 'lib/rmxp_extractor/classnames.rb', line 108

def _dump(limit)
  [@num_of_dimensions, @xsize, @ysize, @zsize, @num_of_elements, @elements].flatten.pack("VVVVVv*")
end

#rmxp_serializeObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rmxp_extractor/ron.rb', line 18

def rmxp_serialize
  str = "Table#{@num_of_dimensions}(\n"
  $indent += 2
  str += "#{"  " * $indent}"
  str += case @num_of_dimensions
    when 1
      "xsize: #{@xsize},\n"
    when 2
      "xsize: #{@xsize}, ysize: #{@ysize},\n"
    when 3
      "xsize: #{@xsize}, ysize: #{@ysize}, zsize: #{@zsize},\n"
    end
  str += "#{"  " * $indent}data: [\n"
  $indent += 2
  case @num_of_dimensions
  when 1
    str += "#{"  " * $indent}"
    @elements.each_with_index do |e, index|
      str += "#{e}, "
      str += "\n#{"  " * $indent}" if (index + 1) % 8 == 0
    end
    str += "\n"
  when 2
    @elements.each do |y|
      str += "  " * $indent
      y.each { |e| str += "#{e}, " }
      str += "\n"
    end
  when 3
    @elements.each do |z|
      z.each do |y|
        str += "  " * $indent
        y.each { |e| str += "#{e}, " }
        str += "\n"
      end
      str += "\n"
    end
  end
  $indent -= 2
  str += "#{"  " * $indent}]\n"
  $indent -= 2
  str += "#{"  " * $indent})"
  str
end