2014-08-13 19:05:00 +02:00
|
|
|
Array.class_eval do
|
2014-08-17 20:44:34 +02:00
|
|
|
def to_sof_node(writer , level)
|
2014-08-18 07:19:48 +02:00
|
|
|
node = Sof::ArrayNode.new()
|
2014-08-15 21:29:48 +02:00
|
|
|
each do |object|
|
2014-08-17 20:44:34 +02:00
|
|
|
node.add writer.to_sof_node( object )
|
2014-08-14 16:40:56 +02:00
|
|
|
end
|
2014-08-15 21:29:48 +02:00
|
|
|
node
|
2014-08-13 19:05:00 +02:00
|
|
|
end
|
|
|
|
end
|
2014-08-18 12:01:52 +02:00
|
|
|
module Sof
|
|
|
|
class ArrayNode < Node
|
|
|
|
def initialize
|
|
|
|
@children = []
|
|
|
|
end
|
|
|
|
attr_reader :children
|
|
|
|
def add c
|
|
|
|
@children << c
|
|
|
|
end
|
|
|
|
def out io , level = 0
|
|
|
|
long_out(io , level)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def long_out io , level
|
|
|
|
indent = " " * level
|
|
|
|
@children.each_with_index do |child , i|
|
|
|
|
io.write "\n#{indent}" unless i == 0
|
|
|
|
io.write "-"
|
|
|
|
child.out(io , level + 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|