Class: Psych::Visitors::YAMLTree
- Inherits:
-
Visitor
- Object
- Visitor
- Psych::Visitors::YAMLTree
- Defined in:
- lib/RGSS/psych_mods.rb
Defined Under Namespace
Classes: Registrar
Instance Method Summary collapse
- #dump_coder(o) ⇒ Object
- #dump_ivars(target) ⇒ Object
- #visit_Hash(o) ⇒ Object
- #visit_Object(o) ⇒ Object
Instance Method Details
#dump_coder(o) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/RGSS/psych_mods.rb', line 100 def dump_coder o @coders << o tag = Psych.[o.class] unless tag klass = o.class == Object ? nil : o.class.name tag = ['!ruby/object', klass].compact.join(':') end c = Psych::Coder.new(tag) o.encode_with(c) register o, emit_coder(c) end |
#dump_ivars(target) ⇒ Object
114 115 116 117 118 119 120 121 122 |
# File 'lib/RGSS/psych_mods.rb', line 114 def dump_ivars target ivars = find_ivars target ivars = ivars.sort() if @options[:sort] ivars.each do |iv| @emitter.scalar("#{iv.to_s.sub(/^@/, '')}", nil, nil, true, false, Nodes::Scalar::ANY) accept target.instance_variable_get(iv) end end |
#visit_Hash(o) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/RGSS/psych_mods.rb', line 62 def visit_Hash o tag = o.class == ::Hash ? nil : "!ruby/hash:#{o.class}" implicit = !tag register(o, @emitter.start_mapping(nil, tag, implicit, Nodes::Mapping::BLOCK)) keys = o.keys keys = keys.sort if @options[:sort] keys.each do |k| accept k accept o[k] end @emitter.end_mapping end |
#visit_Object(o) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/RGSS/psych_mods.rb', line 79 def visit_Object o tag = Psych.[o.class] unless tag klass = o.class == Object ? nil : o.class.name tag = ['!ruby/object', klass].compact.join(':') end if @options[:flow_classes] && @options[:flow_classes].include?(o.class) style = Nodes::Mapping::FLOW else style = Nodes::Mapping::BLOCK end map = @emitter.start_mapping(nil, tag, false, style) register(o, map) dump_ivars o @emitter.end_mapping end |