Class: Enterprise::XMLToSexp

Inherits:
Object
  • Object
show all
Defined in:
lib/enterprise/sexml.rb

Instance Method Summary collapse

Instance Method Details

#visit(node) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/enterprise/sexml.rb', line 11

def visit node
  if ! node['value']
    return s(*node.children.map { |child| child.accept self })
  else
    case node['type']
    when 'Symbol'
      node['value'].to_sym
    when 'Regexp'
      Marshal.load node['value'].unpack('m').first
    when 'NilClass'
      nil
    when 'Fixnum', 'Bignum'
      Integer(node['value'])
    when 'Float'
      Float(node['value'])
    else
      node['value']
    end
  end
end