The XML Registry Objects gem 2.0.0

require 'xmlregistry_objects'


s =<<REG
app/app1
admin: jrobertson
pin_no: 1234

app/app2
admin: dsmith
pin_no: 4321

hkey_network/thinclient
active: false
name: niko2

hkey_apps/email
new: true
last_received: 20-Aug-2014 @ 09:10

hkey_apps/suntimes
sunrise: 05:45
sunset: 08:43
REG

reg = XMLRegistry.new 
reg.import s

# the following nested list maps the registry key with 
#                                        associated object and attributes
list = <<EOF
thinclient = [hkey_network/thinclient]
  active? = Bool active
  name = name
email = [hkey_apps/email]
  new? = Bool new
  recent = last_received
sun = [hkey_apps/suntimes]
EOF
 

h = XMLRegistryObjects.new(reg,list).to_h

h[:sun].sunset      #=> "08:43" 
h[:email].recent    #=> "20-Aug-2014 @ 09:10" 
h[:thinclient].name #=> "niko2"

Resources

Tags:
Source:
0958hrs.txt
Published:
21-08-2014 09:58