Module: RGSS::BasicCoder

Included in:
Game_SelfSwitches, Game_Switches, Game_System, Game_Variables, RPG::System
Defined in:
lib/RGSS/BasicCoder.rb

Constant Summary collapse

INCLUDED_CLASSES =
[]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



31
32
33
# File 'lib/RGSS/BasicCoder.rb', line 31

def self.included(mod)
  INCLUDED_CLASSES.push(mod)
end

.set_ivars_methods(version) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/RGSS/BasicCoder.rb', line 35

def self.set_ivars_methods(version)
  INCLUDED_CLASSES.each do |c|
    if version == :ace
      RGSS::reset_method(c, :ivars, ->{
                     return instance_variables
                   })
    else
      RGSS::reset_method(c, :ivars, ->{
                     return instance_variables.sort
                   })
    end
  end
end

Instance Method Details

#decode(name, value) ⇒ Object



22
23
24
# File 'lib/RGSS/BasicCoder.rb', line 22

def decode(name, value)
  return value
end

#encode(name, value) ⇒ Object



11
12
13
# File 'lib/RGSS/BasicCoder.rb', line 11

def encode(name, value)
  return value
end

#encode_with(coder) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/RGSS/BasicCoder.rb', line 3

def encode_with(coder)
    ivars.each do |var|
    name = var.to_s.sub(/^@/, '')
    value = instance_variable_get(var)
    coder[name] = encode(name, value)
  end
end

#init_with(coder) ⇒ Object



15
16
17
18
19
20
# File 'lib/RGSS/BasicCoder.rb', line 15

def init_with(coder)
  coder.map.each do |key, value|
    sym = "@#{key}".to_sym
    instance_variable_set(sym, decode(key, value))
  end
end

#ivarsObject



26
27
28
# File 'lib/RGSS/BasicCoder.rb', line 26

def ivars
  return instance_variables
end