21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/predicated/from/xml.rb', line 21
def self.convert(node)
node = next_non_text_node(node)
if node.name == "and"
left = next_non_text_node(node.children[0])
right = next_non_text_node(left.next)
And.new(convert(left), convert(right))
elsif node.name == "or"
left = next_non_text_node(node.children[0])
right = next_non_text_node(left.next)
Or.new(convert(left), convert(right))
elsif node.name == "not"
inner = next_non_text_node(node.children[0])
Not.new(convert(inner))
elsif operation_class=OPERATION_TAG_TO_CLASS[node.name]
left = next_non_text_node(node.children[0])
right = next_non_text_node(left.next)
operation_class.new(left.text, right.text)
else
raise DontKnowWhatToDoWithThisXmlTag.new(node.name)
end
end
|