Top Level Namespace
Defined Under Namespace
Modules: RMXPExtractor, RPG
Classes: Array, Color, FalseClass, Hash, NilClass, Numeric, Object, Script, String, Table, Tone, TrueClass
Instance Method Summary
collapse
Instance Method Details
#const_from_string(str) ⇒ Object
1
2
3
4
5
|
# File 'lib/rmxp_extractor/classnames.rb', line 1
def const_from_string(str)
str.split("::").inject(Object) do |mod, class_name|
mod.const_get(class_name)
end
end
|
#create_from_rmxp_serialize(obj) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/rmxp_extractor/classnames.rb', line 7
def create_from_rmxp_serialize(obj)
if obj.is_a?(Hash)
ret = {}
obj.each do |key, value|
if key.is_a?(String) && key.start_with?("class ")
const = const_from_string(key.delete_prefix("class "))
ret = const.new.from_rmxp_serialize(value)
else
if key.is_a?(String) && key =~ /\A[0-9]+\z/ key = key.to_i
end
ret[key] = create_from_rmxp_serialize(value)
end
end
return ret
end
if obj.is_a?(Array)
obj.map! do |value|
create_from_rmxp_serialize(value)
end
end
ret = obj
end
|