class Uaeds::DSML
Public Class Methods
new(xml=nil)
click to toggle source
# File lib/uaeds/dsml.rb, line 3 def initialize(xml=nil) raise ArgumentError, 'Argument is not numeric' unless xml @xml = xml @value_h = {} end
Public Instance Methods
get_value(prop_name)
click to toggle source
# File lib/uaeds/dsml.rb, line 9 def get_value(prop_name) data = get_xml_attr(prop_name) if data.is_a? String return data elsif data.length == 0 return nil elsif data.length == 1 return data[0].content else values = [] data.each { |value| values.push(value.content) } return values end end
get_values(prop_name)
click to toggle source
# File lib/uaeds/dsml.rb, line 24 def get_values(prop_name) data = get_xml_attr(prop_name) if data.length == 0 return [] else values = [] data.each { |value| content.push(value.content) } return values end end
lookup_value(kv)
click to toggle source
# File lib/uaeds/dsml.rb, line 35 def lookup_value(kv) if(@value_h.key? kv) return @value_h[kv] else val = get_value(kv) if val.nil? || (val.length == 0) @value_h[kv] = nil else @value_h[kv] = val end @value_h[kv] end end
Private Instance Methods
get_xml_attr(prop_name)
click to toggle source
# File lib/uaeds/dsml.rb, line 51 def get_xml_attr(prop_name) @xml.xpath("//dsml:attr[@name='#{prop_name}']/dsml:value") end