Module: RPG
Defined Under Namespace
Classes: EventCommand, System
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.array_to_hash(arr, &block) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/RPG.rb', line 8
def self.array_to_hash(arr, &block)
h = {}
arr.each_with_index do |val, index|
r = block_given? ? block.call(val) : val
h[index] = r unless r.nil?
end
if arr.length > 0
last = arr.length - 1
h[last] = nil unless h.has_key?(last)
end
return h
end
|
Instance Method Details
#decode(name, value) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/RPG.rb', line 31
def decode(name, value)
if HASHED_VARS.include?(name)
return hash_to_array(value)
else
return value
end
end
|
#encode(name, value) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/RPG.rb', line 21
def encode(name, value)
if HASHED_VARS.include?(name)
return array_to_hash(value) { |val| reduce_string(val) }
elsif name == 'version_id'
return map_version(value)
else
return value
end
end
|