83: def Editor.model2data(iter)
84: return nil if iter.nil?
85: case iter.type
86: when 'Hash'
87: hash = {}
88: iter.each { |c| hash[c.content] = Editor.model2data(c.first_child) }
89: hash
90: when 'Array'
91: array = Array.new(iter.n_children)
92: iter.each_with_index { |c, i| array[i] = Editor.model2data(c) }
93: array
94: when 'Key'
95: iter.content
96: when 'String'
97: iter.content
98: when 'Numeric'
99: content = iter.content
100: if /\./.match(content)
101: content.to_f
102: else
103: content.to_i
104: end
105: when 'TrueClass'
106: true
107: when 'FalseClass'
108: false
109: when 'NilClass'
110: nil
111: else
112: fail "Unknown type found in model: #{iter.type}"
113: end
114: end