Class: Uaeds::DSML
- Inherits:
-
Object
- Object
- Uaeds::DSML
- Defined in:
- lib/uaeds/dsml.rb
Direct Known Subclasses
Instance Method Summary collapse
- #get_value(prop_name) ⇒ Object
- #get_values(prop_name) ⇒ Object
-
#initialize(xml = nil) ⇒ DSML
constructor
A new instance of DSML.
- #lookup_value(kv) ⇒ Object
Constructor Details
#initialize(xml = nil) ⇒ DSML
Returns a new instance of DSML.
3 4 5 6 7 |
# File 'lib/uaeds/dsml.rb', line 3 def initialize(xml=nil) raise ArgumentError, 'Argument is not numeric' unless xml @xml = xml @value_h = {} end |
Instance Method Details
#get_value(prop_name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# 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) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 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 |